openclaw - 💡(How to fix) Fix Heartbeat scheduler resets on gateway restart instead of maintaining wall-clock cadence [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#59977Fetched 2026-04-08 02:38:02
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
1
Participants

The heartbeat scheduler (configured with every: 2h, activeHours: 07:00–23:00) does not maintain a durable wall-clock-anchored cadence. Instead, the 2h interval timer appears to reset on every gateway restart/reload, causing:

  • Burst clusters of heartbeat fires immediately after restarts
  • Long gaps (hours to days) between fires during stable uptime periods
  • No fires at all on some days during active hours

Error Message

Over 7 days (Mar 26 – Apr 2, 2026), the heartbeat fired 1–3 times per day at best, almost always clustered within minutes of a gateway restart. On multiple days, zero heartbeats fired during the 07:00–23:00 active window.

Root Cause

The heartbeat scheduler (configured with every: 2h, activeHours: 07:00–23:00) does not maintain a durable wall-clock-anchored cadence. Instead, the 2h interval timer appears to reset on every gateway restart/reload, causing:

  • Burst clusters of heartbeat fires immediately after restarts
  • Long gaps (hours to days) between fires during stable uptime periods
  • No fires at all on some days during active hours

Code Example

11:38 AM [heartbeat] started
11:49 AM [heartbeat] started
11:52 AM [heartbeat] started
11:56 AM [heartbeat] started  ← 5 fires in 18 minutes (restart cluster)
11:58 AM [heartbeat] started
12:10 PM [heartbeat] started
3:49 PM  [heartbeat] started  ← 3.5h gap
6:51 PM  [heartbeat] started

---

{
  "heartbeat": {
    "every": "2h",
    "activeHours": { "start": "07:00", "end": "23:00" },
    "model": "anthropic/claude-haiku-4-5",
    "target": "last",
    "lightContext": true
  }
}
RAW_BUFFERClick to expand / collapse

Description

The heartbeat scheduler (configured with every: 2h, activeHours: 07:00–23:00) does not maintain a durable wall-clock-anchored cadence. Instead, the 2h interval timer appears to reset on every gateway restart/reload, causing:

  • Burst clusters of heartbeat fires immediately after restarts
  • Long gaps (hours to days) between fires during stable uptime periods
  • No fires at all on some days during active hours

Expected behavior

Heartbeat should fire at predictable wall-clock anchors (e.g., 7:00, 9:00, 11:00 AM, etc.) independent of when the gateway was last restarted. If the gateway restarts at 10:47 AM, the next heartbeat should still fire at 11:00 AM — not at 12:47 PM.

Observed behavior

Over 7 days (Mar 26 – Apr 2, 2026), the heartbeat fired 1–3 times per day at best, almost always clustered within minutes of a gateway restart. On multiple days, zero heartbeats fired during the 07:00–23:00 active window.

Example log pattern (Mar 30 — a day with many gateway restarts):

11:38 AM [heartbeat] started
11:49 AM [heartbeat] started
11:52 AM [heartbeat] started
11:56 AM [heartbeat] started  ← 5 fires in 18 minutes (restart cluster)
11:58 AM [heartbeat] started
12:10 PM [heartbeat] started
3:49 PM  [heartbeat] started  ← 3.5h gap
6:51 PM  [heartbeat] started

On Apr 1 and Apr 2, only 1 heartbeat fired during the full active window.

Config

{
  "heartbeat": {
    "every": "2h",
    "activeHours": { "start": "07:00", "end": "23:00" },
    "model": "anthropic/claude-haiku-4-5",
    "target": "last",
    "lightContext": true
  }
}

Additional notes

  • A stale Anthropic auth profile was also causing some heartbeat run failures (now fixed separately)
  • target: last may add fragility when no session is recently active — explicit stable targeting would be preferred
  • The issue is the scheduler behavior, not the heartbeat prompt or model

Request

  1. Make heartbeat cadence wall-clock anchored (survives restarts without resetting the interval)
  2. Consider supporting explicit cron-style schedule expressions for heartbeat (e.g., at: ["07:00", "09:00", "11:00", ...]) as an alternative to every: Xh
  3. Clarify/fix target: last behavior when no recent session exists

extent analysis

TL;DR

To achieve a wall-clock-anchored heartbeat cadence, consider implementing a cron-style scheduling system that is not dependent on the gateway's restart time.

Guidance

  • Review the current scheduler implementation to identify why it resets the 2-hour interval timer on every gateway restart, and consider using a persistent storage mechanism to maintain the schedule.
  • Explore using a cron-style scheduling library or system that can handle wall-clock-anchored schedules, such as node-cron or cron-expression, to replace the current every-based scheduling.
  • Consider adding a mechanism to handle the case where the gateway restarts during the inactive hours (23:00-07:00) to ensure the next heartbeat fires at the next scheduled time (07:00) rather than immediately after restart.
  • Evaluate the feasibility of supporting explicit cron-style schedule expressions, such as at: ["07:00", "09:00", "11:00", ...], as an alternative to the every parameter.

Example

{
  "heartbeat": {
    "at": ["07:00", "09:00", "11:00", "13:00", "15:00", "17:00", "19:00", "21:00"],
    "activeHours": { "start": "07:00", "end": "23:00" },
    "model": "anthropic/claude-haiku-4-5",
    "target": "last",
    "lightContext": true
  }
}

Notes

The current implementation's reliance on the every parameter and lack of persistence may be contributing to the observed behavior. A cron-style scheduling system can provide more precise control over the schedule and ensure that the heartbeat cadence is maintained even after gateway restarts.

Recommendation

Apply a workaround by implementing a cron-style scheduling system, as it provides a more robust and reliable way to maintain a wall-clock-anchored heartbeat cadence. This approach can help mitigate the issues caused by the current scheduler's behavior and provide a more predictable heartbeat schedule.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Heartbeat should fire at predictable wall-clock anchors (e.g., 7:00, 9:00, 11:00 AM, etc.) independent of when the gateway was last restarted. If the gateway restarts at 10:47 AM, the next heartbeat should still fire at 11:00 AM — not at 12:47 PM.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING