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

@@ -10,6 +10,7 @@ import {
resolveAgentWorkspaceDir,
resolveDefaultAgentId,
} from "../agents/agent-scope.js";
import { appendCronStyleCurrentTimeLine } from "../agents/current-time.js";
import { resolveUserTimezone } from "../agents/date-time.js";
import { resolveEffectiveMessagesConfig } from "../agents/identity.js";
import { DEFAULT_HEARTBEAT_FILENAME } from "../agents/workspace.js";
@@ -582,14 +583,13 @@ export async function runHeartbeatOnce(opts: {
const pendingEvents = isExecEvent || isCronEvent ? peekSystemEvents(sessionKey) : [];
const hasExecCompletion = pendingEvents.some((evt) => evt.includes("Exec finished"));
const hasCronEvents = isCronEvent && pendingEvents.length > 0;
const prompt = hasExecCompletion
? EXEC_EVENT_PROMPT
: hasCronEvents
? CRON_EVENT_PROMPT
: resolveHeartbeatPrompt(cfg, heartbeat);
const ctx = {
Body: prompt,
Body: appendCronStyleCurrentTimeLine(prompt, cfg, startedAt),
From: sender,
To: sender,
Provider: hasExecCompletion ? "exec-event" : hasCronEvents ? "cron-event" : "heartbeat",