You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Session corrupted when tool execution is aborted - missing tool_result causes API rejection #8312
When a tool execution is aborted (e.g., user cancels during tool run), the session becomes permanently corrupted. Subsequent messages fail with Anthropic API error: tool_use ids were found without tool_result blocks.
Environment
OS: Linux
Provider: Anthropic (Claude)
Steps to Reproduce
Start a conversation that triggers tool calls
Abort/cancel during tool execution (e.g., press Ctrl+C or cancel button)
Try to continue the conversation in the same session
API returns error: messages.N: tool_use ids were found without tool_result blocks immediately after: toolu_XXXXX
Root Cause Analysis
When a tool is aborted, the tool call part is saved with status: "error" and error: "Tool execution aborted":
However, no corresponding tool_result message is created. When the conversation is reconstructed for the next API call, it sends the tool_use block but not a matching tool_result, violating Anthropic's API contract.
Current Behavior in agent.go
In streamAndHandleEvents() (line 350-420), tool results are properly generated for:
These all report the identical Anthropic API validation error: 'tool_use ids were found without tool_result blocks'. Your detailed analysis in #8312 provides excellent root cause context for what appears to be a systemic issue with how tool execution errors and aborts are handled in message reconstruction.
Feel free to ignore if your specific case differs, but these appear to be manifestations of the same underlying problem.
Closing as duplicate of #2720. My root cause analysis may be helpful - the issue is in agent.go where aborted tool calls don't generate tool_result messages.
I also saw Tool execution aborted with {} input (edit tool), and the message ended with finish: "length". That suggests a truncated tool call can create an aborted tool entry; if tool_result is missing, it could still corrupt the session as described here. I have sanitized snippet JSONs if needed.
Activity
github-actions commentedon Jan 14, 2026
This issue might be a duplicate of existing issues. Please check:
tool_useids were found withouttool_resultblocks immediately after #1662: AI_APICallError: tool_use ids were found without tool_result blocks immediately after (occurs with Claude Pro)tool_useids were found withouttool_resultblocks immediately after: toolu_01G5ipgNZWmDHuV6cvzyQpfH. Eachtool_useblock must have a correspondingtool_resultblock in the next message. #2214: AI_APICallError: messages - tool_use ids without tool_result blocks (triggered by interrupting response mid-flight)These all report the identical Anthropic API validation error: 'tool_use ids were found without tool_result blocks'. Your detailed analysis in #8312 provides excellent root cause context for what appears to be a systemic issue with how tool execution errors and aborts are handled in message reconstruction.
Feel free to ignore if your specific case differs, but these appear to be manifestations of the same underlying problem.
popododo0720 commentedon Jan 14, 2026
Closing as duplicate of #2720. My root cause analysis may be helpful - the issue is in
agent.gowhere aborted tool calls don't generatetool_resultmessages.cjmayoral commentedon Feb 11, 2026
I also saw
Tool execution abortedwith{}input (edit tool), and the message ended withfinish: "length". That suggests a truncated tool call can create an aborted tool entry; if tool_result is missing, it could still corrupt the session as described here. I have sanitized snippet JSONs if needed.