openclaw - 💡(How to fix) Fix [Bug]: Heartbeat injects into active sub-agent sessions, terminating them with HEARTBEAT_OK [1 comments, 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#60926Fetched 2026-04-08 02:45:33
View on GitHub
Comments
1
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
commented ×1

Heartbeat prompts are being injected into active sub-agent sessions (agent:<id>:subagent:<uuid>), causing the sub-agent to respond HEARTBEAT_OK instead of completing its actual task. This effectively kills any sub-agent run that spans a heartbeat interval.

Root Cause

Heartbeat prompts are being injected into active sub-agent sessions (agent:<id>:subagent:<uuid>), causing the sub-agent to respond HEARTBEAT_OK instead of completing its actual task. This effectively kills any sub-agent run that spans a heartbeat interval.

Fix Action

Workaround

Extending heartbeat interval to 2hr+ and setting agents.defaults.subagents.runTimeoutSeconds: 600 reduces the collision window but does not eliminate it.

Code Example

seq 36 (user): "System: [2026-04-04 14:31:58 UTC] Exec completed (calm-ree, code 0) :: ...
Read HEARTBEAT.md if it exists (workspace context). Follow it strictly..."

seq 37 (assistant): "HEARTBEAT_OK"
RAW_BUFFERClick to expand / collapse

Description

Heartbeat prompts are being injected into active sub-agent sessions (agent:<id>:subagent:<uuid>), causing the sub-agent to respond HEARTBEAT_OK instead of completing its actual task. This effectively kills any sub-agent run that spans a heartbeat interval.

Steps to Reproduce

  1. Configure heartbeat at 1hr interval (agents.defaults.heartbeat.every: "1h")
  2. Spawn a sub-agent via sessions_spawn with a task that takes >10 minutes (e.g., building a price cache from yfinance, embedding 175K documents into LanceDB)
  3. Wait for the next heartbeat to fire
  4. Observe: the heartbeat prompt is injected into the sub-agent session
  5. The sub-agent responds HEARTBEAT_OK
  6. The announce system picks up HEARTBEAT_OK as the sub-agent result
  7. The actual task work is lost

Evidence

Sub-agent session transcript shows the heartbeat injection as the final exchange:

seq 36 (user): "System: [2026-04-04 14:31:58 UTC] Exec completed (calm-ree, code 0) :: ...
Read HEARTBEAT.md if it exists (workspace context). Follow it strictly..."

seq 37 (assistant): "HEARTBEAT_OK"

This happened to 3 separate sub-agent sessions in the same hour:

  • max-scorecard-v2 — was building a directional call scorecard (task completed but announce returned HEARTBEAT_OK)
  • max-vectordb-v2 — was embedding 175K docs into LanceDB (task completed but announce returned HEARTBEAT_OK)
  • sage-token-optimization — was researching token optimization strategies (stalled after heartbeat injection at ~28 min)

All three were running on anthropic/claude-sonnet-4-6 via sessions_spawn with mode: "run".

Expected Behavior

Heartbeat prompts should never be injected into sub-agent sessions (agent:*:subagent:*). Heartbeats are a main-session concern. Sub-agents have their own task context and should run to completion uninterrupted.

Environment

  • OpenClaw version: 2026.4.1 (upgraded to 2026.4.2 after observing this)
  • OS: Linux 6.8.0-101-generic (x64), Node v22.22.0
  • Model: anthropic/claude-opus-4-6 (main), anthropic/claude-sonnet-4-6 (sub-agents)
  • Channel: Signal
  • Config: agents.defaults.heartbeat.every: "1h", direct Anthropic API key auth

Related Issues

  • #43767 — Heartbeat ignores lightContext: true
  • #56788 — Heartbeat model override ignored
  • #28639 — Heartbeat mixed up with direct chat (suggested fix: "Run heartbeats in an isolated sub-session")

Suggested Fix

The heartbeat runner should skip any session matching the sub-agent session key pattern (agent:*:subagent:*). Heartbeat should only target the main session (agent:*:main).

Workaround

Extending heartbeat interval to 2hr+ and setting agents.defaults.subagents.runTimeoutSeconds: 600 reduces the collision window but does not eliminate it.

extent analysis

TL;DR

Modify the heartbeat runner to skip sessions matching the sub-agent session key pattern (agent:*:subagent:*) to prevent heartbeat prompts from interrupting sub-agent tasks.

Guidance

  • Identify and update the heartbeat runner logic to exclude sub-agent sessions based on the session key pattern.
  • Verify that the updated heartbeat runner correctly targets only main sessions (agent:*:main) and ignores sub-agent sessions.
  • Consider implementing a temporary workaround by extending the heartbeat interval and setting a suitable sub-agent run timeout to reduce the likelihood of collisions.
  • Review related issues (#43767, #56788, #28639) for potential insights into heartbeat behavior and interactions with sub-agent sessions.

Example

No code snippet is provided due to the lack of specific implementation details in the issue.

Notes

The suggested fix assumes that modifying the heartbeat runner is feasible and that the session key pattern can be reliably used to distinguish between main and sub-agent sessions. The effectiveness of the workaround depends on the specific use case and may not completely eliminate collisions.

Recommendation

Apply the suggested fix by modifying the heartbeat runner to skip sub-agent sessions, as this directly addresses the root cause of the issue and provides a more reliable solution than relying on workarounds.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING