ToolMessage] objects to a model during tool calling operations.
The error stems from a fundamental requirement: an assistant message with tool_calls must be followed by tool messages responding to each tool_call_id. When a model returns an AIMessage with tool calls, you must provide exactly one corresponding @[ToolMessage] for each tool call, with matching tool_call_id values.
Common causes
- Insufficient responses: If a model requests two tool executions but you only provide one response message, the model rejects the incomplete message chain
- Duplicate responses: Providing multiple @[
ToolMessage] objects for the same tool call ID results in rejection, as does having unmatched IDs - Orphaned tool messages: Sending a @[
ToolMessage] without a precedingAIMessagecontaining tool calls violates protocol requirements
Troubleshooting
To resolve this error:- Count matching pairs: Ensure one @[
ToolMessage] exists per tool call in the precedingAIMessage - Verify IDs: Confirm each
ToolMessage.tool_call_idmatches an actual tool call identifier
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.