-
-
Notifications
You must be signed in to change notification settings - Fork 39.7k
Description
Bug Description
When cron jobs fire system events, the heartbeat prompt gets appended to ALL events, not just HEARTBEAT events.
Expected Behavior
HEARTBEATevents should get the heartbeat prompt- Other system events (
MORNING_BRIEF,EVENING_DIGEST, custom events, etc.) should NOT get the heartbeat prompt appended
Actual Behavior
All cron-triggered system events receive:
System: [YOUR_EVENT_TEXT]
Read HEARTBEAT.md if it exists (workspace context). Follow it strictly. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.
This causes the agent to treat custom cron events as heartbeats and respond with HEARTBEAT_OK, ignoring the actual event purpose.
Root Cause
In src/infra/heartbeat-runner.ts, when cron jobs call runHeartbeatOnce({ reason: "cron:jobId" }), the function uses the heartbeat prompt as the Body for ALL calls, regardless of whether there are pending system events that should serve as the prompt instead.
Impact
Custom cron workflows that rely on system events (e.g., daily digests, scheduled tasks) get hijacked by the heartbeat prompt. The agent sees "reply HEARTBEAT_OK if nothing needs attention" and complies, never executing the intended workflow.
Proposed Fix
When reason starts with cron: and there are pending system events:
- Use empty
Body(the system event IS the prompt) - Set
Providertocron-eventto distinguish from heartbeats - Don't skip responses that incidentally contain
HEARTBEAT_OKtext