Skip to content
AgenticAIWiki
  1. Learn
  2. Part 7. Tool design and MCP
  3. Chapter 33

The tool use loop

6 lessons · 36 min

The tool use loop

Full screen
questionmessages + toolsUserYour appholds the conversationClaudeMessages APIjsonPOST /v1/messages{ "model": "claude-sonnet-5-5", "tools": [{ "name": "get_weather", "input_schema": { "city": "string" } }], "messages": [{ "role": "user", "content": "Weather in Lisbon?" }]}

Swipe to change step

Step 1 of 9. A user asks What is the weather in Lisbon? Your app owns the conversation: the API is stateless, so every request carries the full history. User. Your app (holds the conversation). Claude (Messages API). arrow from User to Your app, labelled question. arrow from Your app to Claude, labelled messages + tools. a question moving along question.

In this chapter

  1. 33.1Defining tools6 min read
  2. 33.2The request, tool_use, tool_result cycle7 min read
  3. 33.3Parallel tool calls5 min read
  4. 33.4tool_choice: auto, any, a named tool, none5 min read
  5. 33.5Forcing tools to run in order6 min read
  6. 33.6Function calling from first principles7 min read

Chapter check

Already know this? Score 80% or more and you can skip ahead. Each attempt draws 4 questions from 12.

Loading check…