What does a tool_use content block in Claude's response indicate?
tool_use block: When Claude decides to call a tool, the response has stop_reason: 'tool_use' and the content array includes { type: 'tool_use', id: 'toolu_01...', name: 'get_stock_price', input: { ticker: 'AAPL' } }. The input is already a parsed object (not a JSON string, unlike OpenAI). Execute your function using input and return the result.
3 / 5
How do you return a tool_result to Claude in a multi-turn tool loop?
tool_result: After executing the tool, append to messages: { role: 'user', content: [{ type: 'tool_result', tool_use_id: 'toolu_01...', content: JSON.stringify(result) }] }. Call the API with the updated messages. Claude reads the result and either calls another tool or generates the final text response. For errors, add is_error: true to the block.
4 / 5
What is a multi-turn tool loop in the Anthropic API?
Multi-turn loop: Claude may call tools multiple times to gather information before answering. The loop: 1) call API, 2) if stop_reason === 'tool_use', execute all tool_use blocks, 3) append assistant message + tool_result user message, 4) repeat. Continue until stop_reason === 'end_turn'. Set a max iteration limit to prevent runaway loops.
5 / 5
How does tool_choice work in the Anthropic API?
Anthropic tool_choice:{ type: 'any' } forces Claude to call at least one tool from the provided list — useful for guaranteed structured output. { type: 'tool', name: 'extract_data' } forces that exact tool. auto is default. Note: disable_parallel_tool_use: true can be added to force sequential tool calls when the tools have dependencies.