Refer to the exhibit. In a parallel tool-use scenario where Claude generates three such blocks in a single response, how should the orchestration layer handle the 'tool_result' messages to ensure Claude can correctly process the outputs?
Exhibit
{
"type": "tool_use",
"id": "toolu_01",
"name": "get_weather",
"input": {"location": "San Francisco, CA"}
}Trap 1: Combine all three tool outputs into a single 'tool_result' block…
Combining results into one block is incorrect because the model expects a one-to-one mapping between its 'tool_use' IDs and the 'tool_result' blocks. Failing to provide individual results with matching IDs will cause a validation error or cause the model to lose track of which tool call produced which specific piece of data.
Trap 2: Send three separate API requests, each containing one tool result…
While this might work, it is highly inefficient and creates unnecessary round-trips. The Anthropic API is designed to accept multiple 'tool_result' blocks within a single 'user' message. Sending them sequentially significantly increases latency and breaks the parallel nature of the original request, slowing down the overall agentic loop.
Trap 3: Wait for the user to manually approve each tool result before…
While HITL is possible, it is not a requirement for parallel tool use and would drastically impede the performance of an automated agent. The orchestration layer's primary responsibility is to execute the tools and return the data; manual approval should be reserved for high-impact actions rather than every informational tool call.
- A
Combine all three tool outputs into a single 'tool_result' block for efficiency
Why it fails: Combining results into one block is incorrect because the model expects a one-to-one mapping between its 'tool_use' IDs and the 'tool_result' blocks. Failing to provide individual results with matching IDs will cause a validation error or cause the model to lose track of which tool call produced which specific piece of data.
- B
Send three separate API requests, each containing one tool result in sequence
Why it fails: While this might work, it is highly inefficient and creates unnecessary round-trips. The Anthropic API is designed to accept multiple 'tool_result' blocks within a single 'user' message. Sending them sequentially significantly increases latency and breaks the parallel nature of the original request, slowing down the overall agentic loop.
- C
Return a single 'user' message containing three 'tool_result' blocks with matching IDs
This is the correct architectural approach for parallel tool use. By including all results in one 'user' role message, the architect ensures that Claude receives all the requested information at once. Each block must include the 'tool_use_id' that matches the ID from the model's original 'tool_use' request.
- D
Wait for the user to manually approve each tool result before sending them back
Why it fails: While HITL is possible, it is not a requirement for parallel tool use and would drastically impede the performance of an automated agent. The orchestration layer's primary responsibility is to execute the tools and return the data; manual approval should be reserved for high-impact actions rather than every informational tool call.