← Back to PRs

#3335: Fixes cron jobs

by hkirat open 2026-01-28 13:13 View on GitHub →
Fixes https://github.com/moltbot/moltbot/issues/2323 Cron jobs seems to have broken after https://github.com/clawdbot/clawdbot/pull/1535 The reason seems to be an early return that was added in the PR above, that would not the `system events` queue clear if `HEARTBEAT.md` is empty. Cron jobs are pushed to system events when executed, and hence the change ensures that if there are pending system events they should be executed irrespective of the `heartbeat.md` file being empty. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adjusts the heartbeat runner’s “empty HEARTBEAT.md” early-return behavior so that pending system events (e.g., cron-triggered reminders queued into the per-session system-events queue) still cause a heartbeat run. It adds tests covering the new behavior (run when HEARTBEAT.md is effectively empty but system events exist; still skip when empty and no events). The change integrates with existing heartbeat logic by checking the session’s system-events queue before applying the cost-saving skip, ensuring cron/system-event delivery isn’t blocked by an empty heartbeat file. <h3>Confidence Score: 4/5</h3> - This PR is likely safe to merge and addresses the reported cron/system-events regression with targeted tests. - The functional change is small and well-scoped (only gating the empty-heartbeat skip on presence of queued system events) and is covered by new tests. Main remaining risk is around edge cases where `sessionKey` resolution could be invalid and `hasSystemEvents` may throw earlier than before. - src/infra/heartbeat-runner.ts (sessionKey/system-events check edge cases) <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs