PrepGenAICerts

Tool Use Flow & Mechanics

Core

Design and implement agentic loops for autonomous task execution · Difficulty 2/5

0%
tool-usemechanicsapi

Explanation

Tool use in the Claude API follows a structured request-response cycle that your application must implement.

The Tool Use Cycle

  1. Define tools: Provide tool definitions in the API request
  2. Claude selects a tool: Response includes `tool_use` content block with tool name and input
  3. Execute the tool: Your application runs the actual tool/function
  4. Return results: Send tool results back to Claude in a tool_result content block
  5. Claude continues: Uses the results to generate its response or call more tools

Response Structure

When Claude wants to use a tool, the response contains:

  • `stop_reason: "tool_use"`
  • Content blocks of type `tool_use with name, id, and input`

Model-Driven vs Pre-Configured

The distinction matters for architecture:

  • Model-driven: Claude reasons about which tool to call next based on context. More flexible, adapts to novel situations.
  • Pre-configured: Fixed decision trees or tool sequences defined in code. More predictable, but less adaptable.

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

Related Concepts

PrepGenAICerts is an independent exam-prep site. It is not affiliated with, endorsed by, or sponsored by Anthropic, PBC. Claude and Anthropic are trademarks of Anthropic, PBC. Exam details are taken from publicly available Anthropic and Pearson documentation. About PrepGenAICerts.