Thank you for the detailed error messages. These are critical clues.
Anthropic error:
"messages.2.content.0: unexpected tool_use_id found in tool_result blocks: toolu_01BLzUhqM7TxMrF5qoqNWQV1. Each tool_result block must have a corresponding tool_use block in the previous message."
OpenAI error:
"No tool call found for function call output with call_id call_Bzx8BVVl3XNRlqZIJRBUyc23."
Here’s what these mean and where the problem likely lies:
- Both errors indicate a mismatch between the tool call ID in your tool output and the tool call that the model issued in the previous step.
- For OpenAI/Anthropic models, the tool call "ID" (e.g.,
toolu_..., call_...) in your tool result message must exactly match one issued by the model in its prior message's tool_calls array.
Per the docs: "You'd want to check the finish_reason before processing tool calls... The LLM responds with a finish reason of tool_calls, and a tool_calls array. ... process the requested tool calls... messages.append({ 'role': 'tool', 'tool_call_id': tool_call.id, 'content': json.dumps(tool_response) })"
Tool Calling Docs
Please double-check these:</br>
- Are you matching the
tool_call_id in your tool message ("role": "tool", "tool_call_id": ...) to the model's issued tool call in the previous response?</br>
- Are you sure you're not including extra fields? (For Anthropic, make sure you only use expected content fields.)</br>
- Are your messages in this order: user, assistant/tool_call, tool, assistant? (Maintaining strict alternation is required.)
If PDF tools (like mistral-ocr file-parser plugin) behave differently, it's possible their tool call IDs or schema are slightly inconsistent with the expected O...