#15422: fix(auto-reply): keep cron systemEvent payloads that start with 'Read HEARTBEAT.md'
stale
size: XS
Cluster:
Heartbeat Functionality Improvements
## Summary
- stop dropping system events just because text starts with `Read HEARTBEAT.md`
- keep existing heartbeat poll/wake noise filtering unchanged
- add regression tests to ensure user cron payloads with this prefix are preserved
## Why
`compactSystemEvent()` used a text-prefix heuristic that filtered legitimate user-configured cron payloads (issue #15399).
## Testing
- `pnpm --dir /root/clawd/work/openclaw exec vitest run src/auto-reply/reply/session-resets.test.ts`
- `pnpm --dir /root/clawd/work/openclaw exec vitest run src/infra/system-events.test.ts`
Fixes #15399
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This change adjusts `prependSystemEvents` to stop dropping queued system events purely because their text starts with `Read HEARTBEAT.md`, while keeping the existing filtering for heartbeat poll/wake noise.
In context, cron jobs enqueue their payloads into the system-events queue (see `src/gateway/server-cron.ts`), and `prependSystemEvents` is responsible for prefixing that queue into the next prompt. The added regression tests assert that user-configured cron payloads starting with `Read HEARTBEAT.md` are preserved, and that poll/wake noise continues to be removed.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The change is a narrow removal of an over-broad text-prefix filter in `prependSystemEvents`, and tests cover both the regression case and preservation of existing heartbeat poll/wake filtering. Heartbeat prompting itself is handled via the heartbeat runner as a user message, so preserving system events that start with `Read HEARTBEAT.md` aligns with current architecture.
- No files require special attention
<sub>Last reviewed commit: a090aed</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#3335: Fixes cron jobs
by hkirat · 2026-01-28
82.8%
#12365: test(heartbeat): don't skip empty HEARTBEAT.md for cron wake events
by tyclaudius-ai · 2026-02-09
80.3%
#21014: fix(cron): suppress main-session summary for HEARTBEAT_OK responses
by nickjlamb · 2026-02-19
78.7%
#15575: fix(heartbeat): suppress prefixed HEARTBEAT_OK ack replies (#15505)
by TsekaLuk · 2026-02-13
77.6%
#19270: fix: retry event-driven heartbeats blocked by requests-in-flight
by deggertsen · 2026-02-17
77.4%
#17371: fix(heartbeat): always strip HEARTBEAT_OK token from reply text
by BinHPdev · 2026-02-15
76.9%
#6522: fix(cron): deliver original message when agent response is heartbea...
by sidmohan0 · 2026-02-01
76.8%
#22340: fix(heartbeat): drain system events after event-driven heartbeat run
by AIflow-Labs · 2026-02-21
76.3%
#11657: fix(cron): treat skipped heartbeat as ok for one-shot jobs
by DukeDeSouth · 2026-02-08
76.3%
#20521: feat(heartbeat): inject active cron job summary into heartbeat prompt
by maximalmargin · 2026-02-19
75.9%