tool_result block back → Claude answers.
Key points
- Schema:
name,description(3–4 sentences),input_schema(JSON). Tip: have Claude generate the schema from your function. - Message blocks: responses can contain multiple blocks (text + tool_use); append the whole
response.contentto history.stop_reason == "tool_use"means Claude wants a tool. - tool_result goes in a user message:
tool_use_id,content(string),is_error. - Chaining: a
whileloop keeps calling Claude until no tool-use blocks remain. - Batch tool: run multiple tools in parallel in one assistant message.
- Structured data via tools: force a call with
tool_choice; readresponse.content[0].input. - Built-in tools (text-edit, web-search) ship schemas; web-search runs server-side with citations.
Related
Sources
- 2026-06-28-claude-course
Compiled from
wiki/study/claude-course/Tool-Use.md · git is the source of truth