Your user message has tool results and also a text note. The API rejects it. What is wrong?
Why A is the answer
Text came before the tool_result blocks
tool_result blocks must come first in the content array, and any text must follow them. They also have to immediately follow their tool_use blocks.
In detail
- tool_result blocks must come first in the content array.
- Any text has to follow them.
- They must also directly follow their tool_use blocks.
- Build tool messages with a helper, so the order is always right.
Use case
An illustrative scenario, not a real incident.
A developer adds "Here are the results" before the tool results, and the API rejects it. Moving the text after the tool_result blocks fixes it.
See it in different ways
sequenceDiagram participant A as Your code participant C as Claude A->>C: Request with tools C-->>A: tool_use blocks A->>A: Run the tools A->>C: tool_result blocks first, then any text C-->>A: Final answer
flowchart LR S0["tool_result blocks"] --> S1["Then any text"]
Key point: tool_result blocks come first.
Why the other options are wrong
- B. The tool_use_id must be left out
- tool_use_id is required to match each result.
- C. Tool results must go in the system prompt
- Tool results belong in a user message.
- D. Text is never allowed alongside tool results
- Text is allowed, as long as it comes after the tool results.

