Tool Use Flow & Mechanics
CoreDesign and implement agentic loops for autonomous task execution · Difficulty 2/5
Tool use in the Claude API follows a structured request-response cycle that your application must implement.
The Tool Use Cycle
tool_result content blockResponse Structure
When Claude wants to use a tool, the response contains:
with name, id, and input`Model-Driven vs Pre-Configured
The distinction matters for architecture:
Parallel Tool Use
Claude can request multiple tools in a single turn. Return all tool results together before the next API call to minimize round-trips.
Key Takeaways
- ✓Tool use follows a define -> select -> execute -> return cycle
- ✓stop_reason 'tool_use' signals your app should execute the requested tool
- ✓Claude can request multiple tools in parallel to reduce round-trips
- ✓Model-driven tool selection adapts to context; pre-configured sequences are more predictable
Glossary Terms
A content block type in Claude's response indicating the model wants to call a specific tool. Contains 'id', 'name', and 'input' fields. The agent must execute the tool and return results in a tool_result content block for the conversation to continue.
A field in the Claude API response indicating why the model stopped generating. Values: 'end_turn' (natural completion), 'max_tokens' (hit limit), 'stop_sequence' (hit custom stop), 'tool_use' (wants to call a tool). The primary signal for controlling agentic loops.