Check my levelCoursesProgramsFor teamsPricing
UKSign inSign up
Check my levelCoursesProgramsFor teamsPricingClaude quizPromptsBlogFAQSearchSign upUK
AcademlCoursesAI Agents & Tool UseFunction calling in Claude
The agent loop: reason, act, observeA workflow map: a Telegram message branches into command, voice and text and reaches the agentA form request lands in a spreadsheet row labelled “Complaint”
Course

AI Agents & Tool Use

Module 1 · Tool Use Fundamentals
01What tool use is02Function calling in Claude03Function calling in OpenAI04Designing good tools
Module 2 · Agent Architectures
05The ReAct pattern from scratch06Plan-and-Execute and task decomposition07Agent memory08Model Context Protocol (MCP)
Module 3 · Multi-Agent Systems
09Orchestrator and subagents10Agents in LangChain11Microsoft Agent Framework: replacing AutoGen12CrewAI: Crew, Agent, Task, Process
Module 4 · Production Agents
13Human-in-the-loop14Agent observability15Agent security16Deploying agents
AI Agents & Tool Use · Lesson 2

Function calling in Claude

The full tool_use loop in Claude on current models: tool_use and tool_result blocks, parallel calls, tool_choice modes and their limits, structured outputs and strict tool use for strict JSON, and the SDK tool runner.

30 min readUpdated Dec 2, 20264 questions in quizReady prompt included

The tool_use loop in Claude

Claude returns stop_reason: "tool_use", and one or more tool_use blocks appear in content with id, name, input. You run the functions and continue the same conversation: append the full assistant response and a role: "user" message with tool_result blocks.

import anthropic

client = anthropic.Anthropic()

tools = [
    {
        "name": "get_weather",
        "description": "Get current weather for a city. Use when the user asks about weather.",
        "input_schema": {
            "type": "object",
            "properties": {
                "city": {"type": "string", "description": "City name"},
                "units": {"type": "string", "enum": ["celsius", "fahrenheit"]}
            },
            "required": ["city"]
        }
    }
]

messages = [{"role": "user", "content": "What's the weather in Paris?"}]

response = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=4096,
    tools=tools,
    messages=messages,
)

while response.stop_reason == "tool_use":
    results = []
    for block in response.content:
        if block.type != "tool_use":
            continue  # skip text and thinking blocks
        try:
            output = run_weather(block.input["city"])  # your code
            results.append({"type": "tool_result", "tool_use_id": block.id, "content": output})
        except Exception as e:
            results.append({"type": "tool_result", "tool_use_id": block.id,
                            "content": f"Error: {e}", "is_error": True})

The rest of this lesson opens after a free sign-up

Sign up with email or Google: the first two lessons of every course stay open for good, and the whole catalog is open for 7 days. No card needed.

Sign up freeOr a trial lesson, no sign-up →
In this lesson
The tooluse loop in ClaudeParallel callstoolchoice: four modesStrict JSON: structured outputs and strict tool useTool runner: let the SDK run the loopWhen you have many toolsPracticeReady promptQuiz
CoursesLLM coursesFor teamsPricingFAQBlogAboutPrivacy
© 2026 AcademlDevelopment & promotion —MMIX — Marketing Mix
Get started free