Using Anthropic's Claude API tool use, a developer defines a `get_weather` tool and sends a user's question. Claude's response contains a content block requesting that tool be called, along with a unique identifier for that specific request. The developer's code runs the weather lookup and needs to send the result back to Claude in a follow-up request so Claude can use it to answer. How must that result be returned according to Claude's tool-use API?
- As a new message containing a content block whose type marks it as the tool's result and whose identifier matches the unique identifier from Claude's original tool-call block, so Claude can associate the result with the specific request it made
- As plain unstructured text appended to the end of the original user question, with no reference back to which tool call it answers, since Claude infers the link automatically from message order alone
- As a modification to the original request that already contained the tool definitions, replacing the tool's description with the looked-up weather value
- As a system-level instruction rather than as part of the conversation's messages, since tool results are not permitted to appear inside user or assistant messages
Why A? And why not the others?
Correct answer: A. As a new message containing a content block whose type marks it as the tool's result and whose identifier matches the unique identifier from Claude's original tool-call block, so Claude can associate the result with the specific request it made
In Claude's tool-use API, when Claude decides to call a defined tool it returns a content block marking the request along with a unique identifier for that call; the application executes the corresponding function and then sends the result back inside a new message as a content block explicitly marked as the tool's result, carrying that same identifier so Claude can match the result to the specific call it made, even if multiple tool calls were requested at once. The option describing an unstructured text append with no identifier is wrong because Claude's API relies on that explicit identifier match, not on message ordering alone, to associate a result with its originating request. The option describing a modification to the original tool-definition request is wrong because the result is sent as part of the ongoing conversation's messages in a follow-up request, not as an edit to the tool definitions themselves, which stay fixed. The option claiming tool results must appear as a system-level instruction outside the conversation is wrong because the documented round trip places the tool's result inside the message list alongside the user's and Claude's own turns, not in a separate system-level channel.
Source: Anthropic, 'Tool use with Claude' documentation (platform.claude.com/docs/en/agents-and-tools/tool-use/overview): 'the response carries a tool_use block, your code runs the lookup, and a second request sends the result back in a tool_result block'