Anthropic Tool Use
Anthropic tool use is the Claude-specific pattern for exposing callable capabilities through the Messages API. It uses top-level tool definitions plus block-structured assistant/user turns rather than a separate provider-neutral tool role.
Tool definition surface
- Tools are passed in the request
toolsfield. - Each tool definition includes
name,description, andinput_schema. strict: truecan be added when schema conformance matters more than flexible inference.
Tool selection controls
tool_choice: "auto"leaves the decision to the model.tool_choice: "any"requires the model to use at least one provided tool.tool_choice: "tool"forces the model to call a specific named tool.
Execution loop
- The caller sends tool definitions plus a normal Messages API request.
- Claude may return
stop_reason: "tool_use"with one or moretool_usecontent blocks. - The application executes the requested client tool.
- The application sends a follow-up
usermessage whose content begins with the correspondingtool_resultblocks. - Claude resumes generation using those results.
Anthropic-specific constraints
- Tool results must immediately follow the assistant tool-use turn in message history.
- In the
usermessage that returns results,tool_resultblocks must come before any normal text blocks. - Anthropic distinguishes
client toolsfromserver tools. - Client tools execute in the caller's environment; server tools execute on Anthropic infrastructure and do not require the caller to run the operation locally.
Why this matters
- This is function-calling, but with Anthropic-specific transport semantics.
- Generic tool abstractions that assume a dedicated
toolrole need an adaptation layer when targeting Anthropic directly. - Streaming clients may also need to assemble tool arguments incrementally from streamed
input_json_deltaevents.