Claude API error for missing tool results after tool_use
CCAR-F
Agentic Architecture & Orchestration
Medium
Question 39 of 59
You are building an autonomous code maintenance agent with the Claude API to analyze legacy software repositories. When Claude emits a tool_use block requesting execution of a static analysis tool, your agentic loop inserts an intermediate user message containing execution telemetry before appending the tool_result block. In production testing, 100% of these follow-up requests fail with an API error indicating missing tool results.
What change should you make to resolve this API error?
Show answer and explanation
BAppend the tool_result block directly in the message turn immediately following the tool_use turn.
The Claude Messages API strictly requires that tool result blocks immediately follow their corresponding tool use blocks in the conversation history without any intervening messages. Placing an intermediate user message between the assistant tool call and the user tool result violates the API protocol, causing requests to be rejected. Appending the tool result directly in the turn following the tool use restores the required sequence. Inserting a synthetic assistant message does not fix the ordering break and adds artificial conversation turns. Retrying with backoff resends the same malformed history, so every retry fails the same way; this is a structural error, not a transient one. Telemetry can still be sent, as text placed after the tool_result blocks in that same user message. Converting structured tool results into plain text removes the tool result schema that Claude requires to recognize that its requested tool execution has completed.
Source: platform.claude.com/
Anonymous, no account needed. Your tally stays in this browser.