Skip to content

fix: bypass empty-heartbeat-file check for cron jobs#6822

Closed
radling005 wants to merge 1 commit intoopenclaw:mainfrom
radling005:fix/cron-heartbeat-empty-file-bypass-v2
Closed

fix: bypass empty-heartbeat-file check for cron jobs#6822
radling005 wants to merge 1 commit intoopenclaw:mainfrom
radling005:fix/cron-heartbeat-empty-file-bypass-v2

Conversation

@radling005
Copy link

@radling005 radling005 commented Feb 2, 2026

Summary

Cron jobs with wakeMode: 'now' were being skipped when HEARTBEAT.md was empty or contained only comments, even though they had pending system events to process.

Problem

When a cron job fires with wakeMode: 'now', it:

  1. Enqueues the system event via enqueueSystemEvent(text)
  2. Calls runHeartbeatOnce({ reason: 'cron:${job.id}' })

But runHeartbeatOnce() checks if HEARTBEAT.md is effectively empty and skips if so — returning { status: 'skipped', reason: 'empty-heartbeat-file' }.

The bypass only existed for reason === 'exec-event', not for cron jobs.

Fix

Add cron jobs to the bypass list:

const isCronReason = opts.reason?.startsWith('cron:');

This ensures cron-triggered wakes are treated the same as exec-event wakes — both have pending system events that need processing regardless of HEARTBEAT.md state.

Testing

Tested locally with:

  • Cron job with wakeMode: 'now' and empty HEARTBEAT.md
  • Before: lastStatus: 'skipped', lastError: 'empty-heartbeat-file'
  • After: Job executes and delivers as expected

Fixes #4224


Recreated from #4256 which was accidentally closed.

Greptile Overview

Greptile Summary

This PR updates runHeartbeatOnce() to avoid skipping runs triggered by cron jobs when HEARTBEAT.md has no actionable content. Specifically, it extends the existing “exec-event” bypass to also include wake reasons that start with cron: (e.g. cron:<jobId>), so cron-triggered wakeups can process pending system events even if the heartbeat file is empty/comment-only.

The change fits into the heartbeat runner’s early-exit logic that tries to save LLM/API cost by skipping heartbeats when there is nothing actionable in HEARTBEAT.md. Cron jobs with wakeMode: 'now' enqueue work via system events and then call runHeartbeatOnce(), so they need to bypass the empty-file check similar to exec-event wakes.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is narrowly scoped (a simple reason-string check) and only affects the early-skip path for effectively-empty HEARTBEAT.md. It preserves existing behavior for all other reasons and doesn’t alter the main heartbeat execution flow.
  • No files require special attention

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

Context used:

  • Context from dashboard - CLAUDE.md (source)
  • Context from dashboard - AGENTS.md (source)

Cron jobs with wakeMode: 'now' were being skipped when HEARTBEAT.md was
empty or contained only comments, even though they had pending system
events to process.

Add cron jobs to the bypass list alongside exec-events, ensuring
cron-triggered wakes are processed regardless of HEARTBEAT.md state.

Fixes openclaw#4224
@radling005
Copy link
Author

Closing - created prematurely without checking if this was the right approach given existing similar PRs. Apologies for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reminders not working: blocked when heartbeat disabled

1 participant

Comments