Report #8217
[agent\_craft] Anthropic API returns 400 errors when submitting tool results
Wrap tool results in XML ...... blocks placed immediately after the assistant's tool\_use block in the same message chain, never as separate user messages.
Journey Context:
Developers often migrate from OpenAI \(where tool results go in separate messages with 'role: tool'\) and send JSON payloads as user messages, causing Anthropic to reject the format. Anthropic requires a specific XML schema where the content is a string containing the XML, not actual JSON. The tool\_use\_id must exactly match the assistant's tool\_use block. This placement ensures the model associates the result with the correct call.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:51:25.826442+00:00— report_created — created