Skip to content

fix(heartbeat): detect HEARTBEAT_OK through reasoning/thinking blocks - #96356

Closed
moguangyu5-design wants to merge 1 commit into
openclaw:mainfrom
moguangyu5-design:fix/95796-heartbeat-filter-thinking-block
Closed

moguangyu5-design wants to merge 1 commit into
openclaw:mainfrom
moguangyu5-design:fix/95796-heartbeat-filter-thinking-block

Conversation

@moguangyu5-design

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #95796. When the assistant's heartbeat acknowledgement contains silent reasoning/thinking content blocks alongside HEARTBEAT_OK, isHeartbeatOkResponse rejected the whole message as non-text and the heartbeat span was not stripped from the transcript. This inflated context and could confuse the model on the next turn.

Why This Change Was Made

resolveMessageText flagged any block other than text/input_text/output_text as non-text. Reasoning/thinking blocks are internal model output, not meaningful user-visible content, so they should not prevent a plain HEARTBEAT_OK ack from being recognized.

User Impact

Heartbeat prompts/acks are now correctly pruned when the model emits reasoning/thinking blocks, keeping the transcript clean and reducing context noise.

Evidence

  • Added unit tests in src/auto-reply/heartbeat-filter.test.ts covering thinking, redacted_thinking, and mixed tool-use cases.
  • pnpm exec vitest run src/auto-reply/heartbeat-filter.test.ts passes (35/35).
  • pnpm exec oxfmt --check src/auto-reply/heartbeat-filter.ts src/auto-reply/heartbeat-filter.test.ts passes.
  • pnpm exec oxlint --tsconfig config/tsconfig/oxlint.core.json src/auto-reply/heartbeat-filter.ts src/auto-reply/heartbeat-filter.test.ts passes.

🤖 This PR includes code generated by an AI assistant.

isHeartbeatOkResponse previously rejected any assistant message with
non-text content, so a HEARTBEAT_OK ack paired with a reasoning or
thinking block was preserved as a normal turn. Treat thinking and
redacted_thinking blocks as silent internal content so the text ack can
still be recognized and the heartbeat span stripped.

Fixes openclaw#95796
@clawsweeper

clawsweeper Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close: this PR targets a real heartbeat transcript-filter bug, but it is superseded by the open proof-positive candidate at #95798, which covers the reported reasoning shape that this branch omits.

Canonical path: Close this branch and keep the landing discussion on #95798 as the canonical narrow heartbeat-filter fix.

So I’m closing this here and keeping the remaining discussion on #95798.

Review details

Best possible solution:

Close this branch and keep the landing discussion on #95798 as the canonical narrow heartbeat-filter fix.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection shows an assistant content array with a reasoning block plus a text HEARTBEAT_OK block sets hasNonTextContent and makes isHeartbeatOkResponse return false; this branch still lacks that block type.

Is this the best way to solve the issue?

No. The classifier layer is the right fix location, but this branch is not the best landing path because #95798 covers reasoning, thinking, and redacted_thinking with stronger proof.

Security review:

Security review cleared: Cleared: the diff only changes deterministic heartbeat message classification and colocated tests, with no dependency, workflow, secret, or code-execution surface changes.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • nxmxbbd: Authored merged PR fix: remove heartbeat transcript pruning to prevent session corruption #60998, which added src/auto-reply/heartbeat-filter.ts and the initial heartbeat-filter tests. (role: introduced heartbeat filter behavior; confidence: high; commits: 57f9f0a08dd7; files: src/auto-reply/heartbeat-filter.ts, src/auto-reply/heartbeat-filter.test.ts)
  • obviyus: Merged the heartbeat transcript-pruning replacement PR and is tied to landing the current heartbeat-filter baseline in GitHub metadata. (role: merger and adjacent owner; confidence: medium; commits: 57f9f0a08dd7; files: src/auto-reply/heartbeat-filter.ts, src/auto-reply/heartbeat-filter.test.ts)
  • tangtaizong666: Authored merged PR fix(heartbeat): skip reasoning payloads when selecting heartbeat reply #92356 for adjacent heartbeat reasoning-payload selection behavior, which is related to heartbeat reasoning handling but not the same transcript-filter bug. (role: recent adjacent contributor; confidence: medium; commits: 43890ebc3b25; files: src/auto-reply/heartbeat-reply-payload.ts, src/infra/heartbeat-runner.ts)

Codex review notes: model internal, reasoning high; reviewed against c6ade83a5ccb.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Heartbeat transcript filtering ignores HEARTBEAT_OK when assistant message contains reasoning/thinking block

1 participant