Skip to content

Heartbeat prompt appended to all cron system events #3589

@cash-echo-bot

Description

@cash-echo-bot

Bug Description

When cron jobs fire system events, the heartbeat prompt gets appended to ALL events, not just HEARTBEAT events.

Expected Behavior

  • HEARTBEAT events 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:

  1. Use empty Body (the system event IS the prompt)
  2. Set Provider to cron-event to distinguish from heartbeats
  3. Don't skip responses that incidentally contain HEARTBEAT_OK text

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions