fix: process cron job system events during heartbeat execution#7109
fix: process cron job system events during heartbeat execution#7109ArsalanShakil wants to merge 6 commits intoopenclaw:mainfrom
Conversation
Additional Comments (1)
There’s special handling to avoid suppressing exec completions ( If cron reminders are intended to always deliver the reminder text, consider exempting Prompt To Fix With AIThis is a comment left during a code review.
Path: src/infra/heartbeat-runner.ts
Line: 646:659
Comment:
[P1] Cron reminders can still be suppressed as HEARTBEAT_OK tokens
There’s special handling to avoid suppressing exec completions (`shouldSkipMain` ignores `normalized.shouldSkip` when `hasExecCompletion`), but cron reminders don’t get the same exemption. If the model responds with `HEARTBEAT_OK` (or text that strips to empty), `shouldSkipMain` will be true and the reminder may never be delivered.
If cron reminders are intended to always deliver the reminder text, consider exempting `hasCronEvents` from `shouldSkipMain` (and possibly adding a cron fallback similar to `execFallbackText`).
How can I resolve this? If you propose a fix, please make it concise. |
c0c1c32 to
2abf902
Compare
Fixes openclaw#7065 This commit addresses several issues with cron job system events being ignored during heartbeat execution: 1. Exempt cron events from empty HEARTBEAT.md skip - cron events (like exec events) have pending system events to process and should not be skipped when the heartbeat file is empty. 2. Read system events for cron triggers - the heartbeat runner now reads pending system events for cron events (reason starts with "cron:"), not just exec events. 3. Add CRON_EVENT_PROMPT - when a cron event triggers with pending system events, the AI receives a specialized prompt instructing it to relay the reminder instead of the standard heartbeat prompt. 4. Default enabled to true in createJob - cron jobs now default to enabled when not explicitly set. 5. Default wakeMode to "now" for one-shot jobs - one-shot jobs (schedule.kind: "at") now default to wakeMode: "now" for immediate delivery instead of "next-heartbeat". Co-Authored-By: Claude Opus 4.5 <[email protected]>
Address PR review feedback: hasCronEvents now checks for "Cron reminder:" marker instead of just any pending system event, preventing unrelated events from triggering CRON_EVENT_PROMPT.
Simplify the function since Request always has a url property, fixing the no-base-to-string lint error.
e322707 to
b13dd53
Compare
|
I really need this to merge; LGTM! |
|
🔍 Overlapping PRs Detected This PR appears to overlap with 6 other open PRs addressing agents, cron, infra:
🔍 Detected by OpenClaw PR Tracker — AI-powered duplicate detection for open source |
|
Would you consider expanding the PR to also cover the situation where: A system event (not originated from openclaw's cron... just an explicitly sent system event via CLI) was sent with "next-heartbeat" mode, but HEARTBEAT.md is empty. I think this should trigger the next HEARTBEAT run (at its next normal schedule) not being skipped. Currently it is skipped. And i don't think your PR changes that currently? Or advise if you believe this should be a standalone change. |
|
I think a standalone PR would be better here. This PR specifically addresses cron-originated events (identified by the "Cron reminder:" prefix). Generic system events sent via CLI with "next-heartbeat" mode are a slightly different use case - they shouldn't require the cron marker logic. |
Fixes #7065
This commit addresses several issues with cron job system events being ignored during heartbeat execution:
Exempt cron events from empty HEARTBEAT.md skip - cron events (like exec events) have pending system events to process and should not be skipped when the heartbeat file is empty.
Read system events for cron triggers - the heartbeat runner now reads pending system events for cron events (reason starts with "cron:"), not just exec events.
Add CRON_EVENT_PROMPT - when a cron event triggers with pending system events, the AI receives a specialized prompt instructing it to relay the reminder instead of the standard heartbeat prompt.
Default enabled to true in createJob - cron jobs now default to enabled when not explicitly set.
Default wakeMode to "now" for one-shot jobs - one-shot jobs (schedule.kind: "at") now default to wakeMode: "now" for immediate delivery instead of "next-heartbeat".
Greptile Overview
Greptile Summary
This PR improves cron-triggered reminder delivery by ensuring heartbeat runs don’t skip when
HEARTBEAT.mdis effectively empty for cron-triggered runs, and by checking pending system events for cron triggers (not just exec-event triggers). It also introduces a dedicatedCRON_EVENT_PROMPTso cron-triggered reminders are relayed to the user rather than producing a generic heartbeat ack, and updates cron job defaults (enabled defaults to true; one-shotschedule.kind: "at"defaults towakeMode: "now").These changes fit into the existing infra by extending
runHeartbeatOnce’s event-aware prompting (previously only exec completions) to include cron reasons, and by updating cron normalization/job creation defaults to align runtime behavior with the intended delivery semantics.Confidence Score: 4/5
(2/5) Greptile learns from your feedback when you react with thumbs up/down!
Context used:
dashboard- CLAUDE.md (source)dashboard- AGENTS.md (source)