Перевірити рівеньКурсиПрограмиДля командТарифи
RUУвійтиРеєстрація
Перевірити рівеньКурсиПрограмиДля командТарифиТест із ClaudeПромптиБлогПитання та відповідіПошукРеєстраціяRU
AcademlКурсиAI Agents & Tool UseFunction calling in Claude
Цикл агента: думка, дія, спостереженняСхема сценарію: повідомлення в Telegram розходиться на команду, голос і текст і приходить до агентаЗаявка з форми потрапляє в рядок таблиці з міткою «Скарга»
Курс

AI Agents & Tool Use

Модуль 1 · Tool Use Fundamentals
01What tool use is02Function calling in Claude03Function calling in OpenAI04Designing good tools
Модуль 2 · Agent Architectures
05The ReAct pattern from scratch06Plan-and-Execute and task decomposition07Agent memory08Model Context Protocol (MCP)
Модуль 3 · Multi-Agent Systems
09Orchestrator and subagents10Agents in LangChain11Microsoft Agent Framework: replacing AutoGen12CrewAI: Crew, Agent, Task, Process
Модуль 4 · Production Agents
13Human-in-the-loop14Agent observability15Agent security16Deploying agents
AI Agents & Tool Use · Урок 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.

ENМатеріали курсів поки англійською. Інтерфейс, ШІ-наставник і перевірка завдань — українською.

30 хв читанняОновлено 02.12.20264 питання у квізіГотовий промпт включено

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})

Далі урок відкривається після безкоштовної реєстрації

Реєстрація через email або Google відкриває перші два уроки кожного курсу назавжди і 7 днів повного доступу до всього каталогу. Картка не потрібна.

Зареєструватися безкоштовноАбо пробний урок без реєстрації →
У цьому уроці
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 toolsПрактикаГотовий промптКвіз
КурсиКурси з LLMДля командТарифиПитання та відповідіБлогПро насКонфіденційність
© 2026 AcademlРозробка та просування сайтів —MMIX — Marketing Mix
Почати безкоштовно