Repository navigation
fix: heartbeat filter ignores reasoning/thinking blocks in HEARTBEAT_OK detection - #96021
pengxuewu-lab wants to merge 1 commit into
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: the same heartbeat reasoning/thinking ACK bug is already owned by a proof-positive, mergeable candidate, and this branch fixes it by removing a broader safety guard that should be preserved. Canonical path: Land one canonical narrow heartbeat-filter fix, preferably #95798, then close the duplicate candidate PRs for the linked bug. So I’m closing this here and keeping the remaining discussion on #95798. Review detailsBest possible solution: Land one canonical narrow heartbeat-filter fix, preferably #95798, then close the duplicate candidate PRs for the linked bug. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection gives a high-confidence path: an assistant content array with a reasoning/thinking block plus Is this the best way to solve the issue? No. The branch is a plausible fix for the reported shape, but the best fix is the narrower classifier carve-out used by the canonical candidate so other non-text content remains protected. Security review: Security review 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:
Codex review notes: model internal, reasoning high; reviewed against d1b917120a47. |
What Problem This Solves
Heartbeat filtering in
isHeartbeatOkResponse()incorrectly rejectedHEARTBEAT_OKresponses whenever the assistant message contained reasoning or thinking blocks alongside the heartbeat token. TheresolveMessageText()helper returnshasNonTextContent: truefor any content block that is not plain text (includingreasoningandthinkingblocks), and the pre-existing code used this flag as an earlyreturn falsegate.Impact: Agents that emit reasoning/thinking blocks (e.g. Claude with extended thinking, Codex with reasoning_effort) could never pass the heartbeat OK check. Heartbeat acknowledgements were silently ignored, causing unnecessary re-scheduling of heartbeat turns.
Root cause:
src/auto-reply/heartbeat-filter.ts—isHeartbeatOkResponse()checkedhasNonTextContentfromresolveMessageText()and returned false before reachingstripHeartbeatToken(), even when the text content contained a validHEARTBEAT_OKtoken.Evidence
Targeted tests (heartbeat-filter.test.ts)
Three new test cases added, all passing:
[{type:"reasoning",...}, {type:"text",text:"HEARTBEAT_OK"}]true[{type:"thinking",...}, {type:"text",text:"HEARTBEAT_OK"}]truefalse(respects length cap)Fix (heartbeat-filter.ts)
Removed two lines — the
hasNonTextContentearly return gate. ThestripHeartbeatToken()call on line 340 already handles text extraction correctly regardless of non-text blocks:Why this is safe
tool_callblocks are still explicitly rejected by the precedinghasAssistantToolCall()checkstripHeartbeatToken()still enforces theackMaxCharslimit — long responses with reasoning are correctly rejected when text exceeds the cap (proven by the third test case)HEARTBEAT_OKtoken continue to returnfalsesincestripHeartbeatToken()finds no match🤖 Generated with Claude Code