Skip to content

[Bug]: Heartbeat handler re-triggers on subagent auto-announcement events, causing cascade of heartbeat polls. #56049

@YoussefAlayyoub

Description

@YoussefAlayyoub

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When a main session has an unread heartbeat prompt (system message) and subagent sessions complete with auto-announce enabled, the subagent result messages insert into the main session's message queue. Each insertion re-triggers the heartbeat handler, causing heartbeat polls to fire in rapid succession (every ~18s) instead of at the configured interval.

Steps to reproduce

1- Spawn multiple subagents from the main session
2- Allow subagents to complete and auto-announce results to the main session
3- Trigger a heartbeat (new session, /reset, or scheduled interval)
4- Observe heartbeat firing 5-6+ times in rapid succession

Expected behavior

Heartbeat fires once at the configured interval. Subagent auto-announcements should not re-trigger the heartbeat handler.

Actual behavior

Heartbeat fires repeatedly — 6 times in ~60 seconds observed (~18s apart), matching the rate at which subagent result announcements insert into the session queue.

OpenClaw version

OpenClaw 2026.3.24

Operating system

Ubuntu 24.04 LXC / Proxmox

Install method

npm global

Model

minimax-m2.7:cloud

Provider / routing chain

openclaw -> heartbeat

Additional provider/model setup details

Session kind: webchat
Related issues: #50398 (heartbeat triggered by subagent exec completion — same root cause)

Logs, screenshots, and evidence

Impact and severity

Severity: Medium — causes token burn from repeated HEARTBEAT_OK processing, obscures actual session activity in logs.

Additional information

Proposed fix:
The heartbeat handler should be idempotent with respect to pending subagent announcements — either:

1- Mark the heartbeat as "consumed" once handled per heartbeat interval, preventing re-trigger from stacked announcements, OR
2- Detect whether the session has processed a user message since the last heartbeat and skip if the pending heartbeat is stale

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions