openclaw - ✅(Solved) Fix [Bug]: Heartbeat events can preempt the active user-facing reply lane [1 pull requests, 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#68182Fetched 2026-04-18 05:53:36
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×2cross-referenced ×1referenced ×1

Heartbeat events can preempt the active user-facing reply lane and replace an in-progress assistant reply with internal control output such as HEARTBEAT_OK.

Root Cause

In practice, the conversation flow looks broken because internal runtime/system output is allowed to surface in the same lane as the active end-user exchange.

Fix Action

Fixed

PR fix notes

PR #68189: fix: prevent heartbeat events from preempting user-facing reply lane

Description (problem / solution / changelog)

Summary

This fix prevents heartbeat events from preempting active user-facing replies by adding a check for replyRunRegistry.isActive(sessionKey) before proceeding with heartbeat processing.

The issue occurred because the queue size check alone was insufficient - work can be dequeued while still actively processing (streaming). The heartbeat would then proceed and deliver its output, which could preempt or interrupt the in-progress user-facing reply.

Changes

  • Added import of replyRunRegistry from ../auto-reply/reply/reply-run-registry.js
  • Added isReplyRunActive optional dependency to HeartbeatDeps type for testability
  • Added check for replyRunRegistry.isActive(sessionKey) after the session lane queue size check
  • Added test case "returns requests-in-flight when reply run is active for session"
  • Updated existing test to also verify the new check is called

Testing

  • Added new test case to heartbeat-runner.skips-busy-session-lane.test.ts that verifies heartbeat skips when isReplyRunActive returns true
  • Updated existing test to include the isReplyRunActive dependency
  • TypeScript syntax verified (vitest unavailable in this environment)

Fixes openclaw/openclaw#68182

Changed files

  • src/infra/heartbeat-runner.skips-busy-session-lane.test.ts (modified, +54/-1)
  • src/infra/heartbeat-runner.ts (modified, +18/-0)

Code Example

Observed visible symptoms include:
- the conversation being interrupted by a heartbeat instruction,
- the reply collapsing into only `HEARTBEAT_OK`,
- maintenance/system-event text surfacing in the same user-facing lane.

This appears to be more than background noise: it directly breaks the continuity of the live conversation.
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Heartbeat events can preempt the active user-facing reply lane and replace an in-progress assistant reply with internal control output such as HEARTBEAT_OK.

Steps to reproduce

Observed in a real user-facing conversation:

  1. Start a normal live conversation in the main user-facing lane.
  2. Ask the assistant to perform a multi-step task or prepare a follow-up reply.
  3. While the assistant is still actively handling the turn, let a heartbeat event arrive.
  4. Observe that the visible reply may be preempted and replaced by internal output such as:
    • HEARTBEAT_OK
    • heartbeat protocol text
    • background maintenance/status text

Expected behavior

Heartbeat events should not occupy or interrupt the active user-facing reply lane.

They should either:

  • remain silent,
  • be routed to a separate internal/debug lane,
  • or be deferred until the active user-visible reply completes.

Actual behavior

Heartbeat and related system events can take over the current visible reply slot in the main user-facing conversation.

This causes the assistant's normal reply to be interrupted, displaced, or effectively lost from the user's perspective.

OpenClaw version

v2026.4.15

Operating system

Linux (containerized deployment)

Install method

Docker / containerized deployment

Model

Observed in a live deployment; the user-visible symptom does not appear tied to one specific model.

Provider / routing chain

Observed in the main user-facing lane of a live deployment. Exact provider/model routing was not isolated as the primary variable for this issue.

Additional provider/model setup details

Issue reproduced in a real user-facing deployment. The visible failure mode appears tied to heartbeat/system-event delivery into the active conversation lane rather than a provider-specific model behavior.

Logs, screenshots, and evidence

Observed visible symptoms include:
- the conversation being interrupted by a heartbeat instruction,
- the reply collapsing into only `HEARTBEAT_OK`,
- maintenance/system-event text surfacing in the same user-facing lane.

This appears to be more than background noise: it directly breaks the continuity of the live conversation.

Impact and severity

This is user-visible and confusing.

It makes the assistant appear unreliable or non-responsive even when the underlying task has not actually been abandoned.

In practice, the conversation flow looks broken because internal runtime/system output is allowed to surface in the same lane as the active end-user exchange.

Additional information

Regardless of internal intent, allowing background heartbeat/system output to occupy the same visible reply path as the active end-user conversation produces a user-facing failure.

Potentially related to #67178 ([Bug] Context Engine Turn Maintenance Loop), but this report is specifically about heartbeat/system events preempting the active user-facing reply lane.

extent analysis

TL;DR

Implement a mechanism to prioritize user-facing replies over heartbeat events in the main conversation lane.

Guidance

  • Identify the current logic for handling heartbeat events and user-facing replies in the main conversation lane.
  • Consider implementing a queue or buffer to hold heartbeat events until the active user-facing reply is complete.
  • Develop a conditional check to prevent heartbeat events from preempting the active user-facing reply lane.
  • Review the related issue #67178 ([Bug] Context Engine Turn Maintenance Loop) for potential insights into the underlying cause.

Example

# Pseudocode example of conditional check
if is_user_facing_reply_in_progress():
    # Defer heartbeat event until reply is complete
    defer_heartbeat_event()
else:
    # Process heartbeat event
    process_heartbeat_event()

Notes

The exact implementation will depend on the specific architecture and logic of the conversation handling system. This guidance is intended to provide a general direction for resolving the issue.

Recommendation

Apply a workaround to prioritize user-facing replies over heartbeat events, such as implementing a queue or buffer to hold heartbeat events until the active user-facing reply is complete. This will help prevent heartbeat events from preempting the active user-facing reply lane and improve the overall user experience.

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 events should not occupy or interrupt the active user-facing reply lane.

They should either:

  • remain silent,
  • be routed to a separate internal/debug lane,
  • or be deferred until the active user-visible reply completes.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: Heartbeat events can preempt the active user-facing reply lane [1 pull requests, 1 participants]