fix: skip synthetic tool_result for aborted assistant messages#6831
Closed
zerone0x wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix: skip synthetic tool_result for aborted assistant messages#6831zerone0x wants to merge 1 commit intoopenclaw:mainfrom
zerone0x wants to merge 1 commit intoopenclaw:mainfrom
Conversation
4 tasks
This was referenced Feb 8, 2026
Contributor
Supporting This PRI independently implemented the same fix and submitted PR #11729 (now closed as duplicate). After reviewing the 10+ duplicate PRs, this one (#6831) appears to be the best solution. Why this PR should be merged:
Testing verification:
Impact on production: To maintainers: Please prioritize merging this PR. There are 10+ duplicates submitted over the past 11 days, all trying to fix the same issue. This is one of the cleanest implementations. Tested-by: @rodbland2021 |
Member
|
Closing as duplicate of #4844. If this is incorrect, comment and we can reopen. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6788
When a user interrupts an assistant mid-tool-call, the message gets
stopReason: "aborted"but the transcript repair logic still extracts tool call IDs from the partial content and creates synthetictool_resultentries. Anthropic's API then rejects the transcript withinvalid_request_error: unexpected tool_result block, making the session unusable.Changes
session-transcript-repair.ts:extractToolCallsFromAssistant()now returns[]for messages withstopReason === "aborted", preventing synthetic tool_result generation for incomplete tool callssession-tool-result-guard.ts: Same check in the guard'sextractAssistantToolCalls()to prevent queuing pending results for aborted messagessession-transcript-repair.test.ts: Added 2 tests verifying the fixTest Plan
Generated with Claude Code (issue-hunter-pro)
Co-Authored-By: Claude noreply@anthropic.com
Greptile Overview
Greptile Summary
This PR updates transcript repair and tool-result guarding to treat
stopReason: "aborted"assistant messages as having no tool calls, preventing generation/queuing of synthetictoolResultblocks from partial tool-call content. It also adds unit tests covering the aborted vs non-aborted transcript-repair behavior to avoid Anthropic API rejections caused by unexpectedtool_resultblocks in repaired transcripts.Confidence Score: 5/5
stopReason === "aborted") in two extraction helpers, and transcript-repair behavior is covered by new tests. No behavioral impact for non-aborted messages, and the new condition is narrowly scoped.Context used:
dashboard- CLAUDE.md (source)dashboard- AGENTS.md (source)