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
Getting a repeated error when using Roo-Code with the Anthropic API:
LLM request rejected: messages.98.content.1: unexpected tool_use_id found in tool_result blocks: toolu_0114eUeLnM3d16LHL9X69Y92. Each tool_result block must have a corresponding tool_use block in the previous message.
The error persists across retries with the same tool_use_id, suggesting the conversation history is replayed with the same corrupted state.
Expected Behavior
The conversation should continue without API validation errors.
Likely Cause
A tool_result block in the conversation history references a tool_use_id that no longer has a matching tool_use block in the preceding assistant message. This can happen when conversation history is truncated or summarized — if the assistant message containing the tool_use is removed but the following user message with the tool_result is kept, the pairing breaks.
Suggested Fix
Treat tool_use/tool_result pairs as atomic units when trimming conversation context — never remove one without the other.
Validate the message array before sending to the API to ensure every tool_result.tool_use_id has a corresponding tool_use block in the immediately preceding assistant message.
Environment
API: Anthropic (Claude)
The error occurs at message index 98, suggesting it happens in longer conversations after context management kicks in.
Bug Description
Getting a repeated error when using Roo-Code with the Anthropic API:
The error persists across retries with the same
tool_use_id, suggesting the conversation history is replayed with the same corrupted state.Expected Behavior
The conversation should continue without API validation errors.
Likely Cause
A
tool_resultblock in the conversation history references atool_use_idthat no longer has a matchingtool_useblock in the preceding assistant message. This can happen when conversation history is truncated or summarized — if the assistant message containing thetool_useis removed but the following user message with thetool_resultis kept, the pairing breaks.Suggested Fix
tool_use/tool_resultpairs as atomic units when trimming conversation context — never remove one without the other.tool_result.tool_use_idhas a correspondingtool_useblock in the immediately preceding assistant message.Environment