- Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
https://codercom.slack.com/archives/C093W1J73V0/p1761009411681159
Problem
When the agent is stopped while making an MCP call, a tool_use block is written but no corresponding tool_result block exists (because the call was canceled). This causes the conversation to be broken forever with the error:
`tool_use` ids were found without `tool_result` blocks immediately after <the id> Context
This appears to be a state management issue where messages are stored even when tool execution is incomplete or canceled. The conversation becomes permanently broken after this happens.
Potential Solutions
- Don't store messages unless we have the result - Only persist the message once the tool_result is available
- Add a "cancelled" result block - When cancellation occurs, inject a tool_result block with a cancellation error
- Research API best practices - Investigate if there's an expected way to handle this according to the API specification
Impact
This breaks the conversation flow permanently and requires the user to start a new conversation or manually delete the tool_use block from the context.