Heartbeat: inject cron-style current time into prompts (#13733)

* Heartbeat: inject cron-style current time into prompts

* Tests: fix type for web heartbeat timestamp test

* Infra: inline heartbeat current-time injection
This commit is contained in:
Tak Hoffman
2026-02-10 18:58:45 -06:00
committed by GitHub
parent a853ded782
commit d2c2f4185b
6 changed files with 98 additions and 17 deletions

View File

@@ -12,11 +12,7 @@ import {
import { runCliAgent } from "../../agents/cli-runner.js";
import { getCliSessionId, setCliSessionId } from "../../agents/cli-session.js";
import { lookupContextTokens } from "../../agents/context.js";
import {
formatUserTime,
resolveUserTimeFormat,
resolveUserTimezone,
} from "../../agents/date-time.js";
import { resolveCronStyleNow } from "../../agents/current-time.js";
import { DEFAULT_CONTEXT_TOKENS, DEFAULT_MODEL, DEFAULT_PROVIDER } from "../../agents/defaults.js";
import { loadModelCatalog } from "../../agents/model-catalog.js";
import { runWithModelFallback } from "../../agents/model-fallback.js";
@@ -288,11 +284,7 @@ export async function runCronIsolatedAgentTurn(params: {
to: deliveryPlan.to,
});
const userTimezone = resolveUserTimezone(params.cfg.agents?.defaults?.userTimezone);
const userTimeFormat = resolveUserTimeFormat(params.cfg.agents?.defaults?.timeFormat);
const formattedTime =
formatUserTime(new Date(now), userTimezone, userTimeFormat) ?? new Date(now).toISOString();
const timeLine = `Current time: ${formattedTime} (${userTimezone})`;
const { formattedTime, timeLine } = resolveCronStyleNow(params.cfg, now);
const base = `[cron:${params.job.id} ${params.job.name}] ${params.message}`.trim();
// SECURITY: Wrap external hook content with security boundaries to prevent prompt injection