Repository navigation
fix(heartbeat): allow reasoning/thinking blocks in heartbeat ack filt… - #95798
hanZeng-08 wants to merge 1 commit into
Conversation
2b5274b to
034787c
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Codex review: needs maintainer review before merge. Reviewed June 26, 2026, 4:34 AM ET / 08:34 UTC. Summary PR surface: Source +12, Tests +69. Total +81 across 2 files. Reproducibility: yes. Source inspection of current main shows a thinking/reasoning block sets hasNonTextContent and makes isHeartbeatOkResponse return false before HEARTBEAT_OK stripping runs; I did not execute tests in this read-only cleanup review. Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land one canonical narrow heartbeat-filter fix that treats only internal reasoning blocks as invisible while preserving tool/media guards, then close duplicate candidate PRs after the linked bug is fixed. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection of current main shows a thinking/reasoning block sets hasNonTextContent and makes isHeartbeatOkResponse return false before HEARTBEAT_OK stripping runs; I did not execute tests in this read-only cleanup review. Is this the best way to solve the issue? Yes. The PR fixes the classifier at the right narrow layer and is better than removing the non-text guard entirely because it keeps tool/media content from being misclassified as a silent heartbeat ACK. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9a735bea03f6. Label changesLabel justifications:
Evidence reviewedPR surface: Source +12, Tests +69. Total +81 across 2 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Hi! This PR is ready for maintainer review — ClawSweeper has re-reviewed it and rated it platinum hermit (status: 👀 ready for maintainer look). It fixes the heartbeat filtering issue where reasoning/thinking blocks incorrectly prevent HEARTBEAT_OK detection. Could a maintainer please take a look when you have a moment? Thanks! 🙏 /cc @obviyus @vincentkoc |
1 similar comment
|
Hi! This PR is ready for maintainer review — ClawSweeper has re-reviewed it and rated it platinum hermit (status: 👀 ready for maintainer look). It fixes the heartbeat filtering issue where reasoning/thinking blocks incorrectly prevent HEARTBEAT_OK detection. Could a maintainer please take a look when you have a moment? Thanks! 🙏 /cc @obviyus @vincentkoc |
|
Hi! This PR is ready for maintainer review — ClawSweeper has re-reviewed it and rated it platinum hermit (status: 👀 ready for maintainer look). It fixes the heartbeat filtering issue where reasoning/thinking blocks incorrectly prevent HEARTBEAT_OK detection. Could a maintainer please take a look when you have a moment? Thanks! 🙏 /cc @obviyus @vincentkoc |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
Fixes #95796
Summary
Problem: Heartbeat transcript filtering inconsistently preserved or removed suppressed HEARTBEAT_OK turns from model request history depending on whether the final assistant message contained non-text reasoning/thinking content. When the assistant's heartbeat acknowledgement included a
thinking,reasoning, orredacted_thinkingblock, the entire heartbeat prompt/ack pair was left in the context, wasting tokens and polluting the model prompt.Solution: Treat model-internal reasoning/thinking blocks as invisible to the heartbeat filter.
resolveMessageTextnow skipsthinking/reasoning/redacted_thinkingblock types when computinghasNonTextContent, allowingisHeartbeatOkResponseto correctly recognize short HEARTBEAT_OK acks even when the model emits reasoning alongside the text response.What changed:
resolveMessageTextinheartbeat-filter.tsto ignore reasoning blocks; added regression tests inheartbeat-filter.test.tsforisHeartbeatOkResponseandfilterHeartbeatTranscriptArtifactswith reasoning/thinking blocks.redacted_thinkingto the skipped reasoning block types (was missing in the original fix).resolveMessageTextto explain WHY reasoning blocks are skipped (ephemeral model artifacts, not user-visible content).tool_use) to ensure it correctly returnsfalse.What did NOT change: Heartbeat token detection logic, maxAckChars enforcement, tool-call handling in heartbeat filtering, user-message heartbeat prompt detection, or the
stripHeartbeatTokencontract.Real behavior proof
Behavior addressed: Assistant messages containing both a reasoning block and a short HEARTBEAT_OK text block were incorrectly classified as non-heartbeat content, causing the heartbeat span to remain in the transcript.
Real environment tested: Linux, Node v22.23.0, OpenClaw worktree SHA 034787c
Exact steps or command run after this patch:
Evidence after fix:
Before evidence (Negative control — old code):
Output:
Test suite results:
pnpm test src/auto-reply/heartbeat-filter.test.ts --runOutput:
All 37 tests pass. Key regression assertions:
matches heartbeat acks that include reasoning blocks— verifiesisHeartbeatOkResponsereturnstruefor assistant messages withthinking/reasoning/redacted_thinkingblocks +HEARTBEAT_OKtextremoves heartbeat pairs where the assistant response includes reasoning blocks— verifiesfilterHeartbeatTranscriptArtifactsstrips the full heartbeat span from the transcript when the assistant ack includes reasoning blocksdoes not match heartbeat when reasoning is mixed with non-text content— verifiesisHeartbeatOkResponsereturnsfalsewhen reasoning is mixed with tool calls or other non-text contentObserved result after fix: Messages like
[{ type: "thinking", thinking: "Checking..." }, { type: "text", text: "HEARTBEAT_OK" }]are now correctly recognized as heartbeat acks and removed from the transcript.What was not tested: Live model streaming with actual heartbeat reasoning blocks; the fix is verified through unit tests and the logic path is deterministic.
Regression Test Plan
Coverage level: Unit-fast regression tests
Target test file:
src/auto-reply/heartbeat-filter.test.tsScenario locked in:
isHeartbeatOkResponsereturnstruefor assistant messages containingthinking/reasoning/redacted_thinkingblocks alongside a short HEARTBEAT_OK text block.filterHeartbeatTranscriptArtifactsremoves the full heartbeat span (user prompt + assistant ack) when the assistant ack includes reasoning blocks.isHeartbeatOkResponsereturnsfalsewhen reasoning blocks are mixed with other non-text content (e.g.,tool_use), ensuring we don't over-match.Why this is the smallest reliable guardrail: The three new tests cover the exact boundary that was broken (
resolveMessageTextflagging reasoning blocks as non-text), the end-to-end behavior (filterHeartbeatTranscriptArtifactsspan removal), and a safety boundary (reasoning + non-text returns false), without touching other heartbeat logic paths.Root Cause
Root cause:
resolveMessageTextiterated over every block in the message content array and sethasNonTextContent = truefor any block type other thantext/input_text/output_text. This included model-internal reasoning blocks (thinking,reasoning,redacted_thinking), which are not user-visible and should not disqualify a message from being a heartbeat ack.Missing detection / guardrail: Existing tests covered heartbeat filtering with plain text, tool calls, and tool results, but did not test the case where a heartbeat ack message contained reasoning blocks. The
hasNonTextContentcheck was too broad and lacked a carve-out for reasoning content.Risk checklist
AI-assisted.