Learning resourcesReviewed · Anthropic

Handle tool calls

Handle tool calls is a guide for developers connecting Claude to tools, with the catch that manual handling makes your application responsible for execution and correct message formatting. It explains tool_use and tool_result blocks, client and server tool interactions, and error recovery.

Researched 24 Nov 2026

In short.

Handle tool calls is a Claude API guide for developers building applications that use tools, with the catch that mistakes in the manual message sequence can cause API errors. It explains how to execute client tool requests, match results to calls, preserve conversation history and handle failures. Particularly useful details cover computer and browser tool results and turns containing unfinished server tool calls. The page offers payload examples rather than a complete application; operating costs, runtime reliability and SDK compatibility are not established.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete page at [https://platform.claude.com/docs/en/agents-and-tools/tool-use/handle-tool-calls.md], including its examples, client and server handling, computer and browser result restrictions, formatting notices, error guidance and prompt-injection warning. Linked pages are excluded, including the SDK runner, complete tutorial, strict tool use, parallel tool use, stop reasons and further security guidance. No examples or tools were executed; runtime behavior, performance, costs and deployment outcomes remain unverified.

The overview

Identity

Handle tool calls is a Claude platform documentation page available at [https://platform.claude.com/docs/en/agents-and-tools/tool-use/handle-tool-calls.md]. Its subject is the application code that receives Claude's tool requests, executes client tools and sends results back.

The resource is instructional documentation. Its examples illustrate API message structures; it does not supply an installable tool or a complete agent implementation.

Assessment

The guide is useful when developers need custom control over tool execution or are diagnosing malformed tool conversations. It gives specific rules for matching call identifiers, positioning results and continuing turns that involve both client and server tools.

Its strength is protocol detail. It does not establish implementation effort, execution reliability or performance, and it directs readers elsewhere for complete programs.

Users

Developers building their own Claude tool-execution loop are the primary audience. Beginners get concrete JSON examples, but need enough programming knowledge to execute functions, manage message history and make another API request.

Experienced developers will find the special cases particularly relevant: dispatching computer and browser tool members, returning every client result after multiple calls, and continuing an unfinished server tool call. Readers who want automatic orchestration are directed to the SDK tool runner.

Capabilities

The page explains how to read a tool_use block's id, name and input, then answer it with a tool_result carrying the matching tool_use_id. A generic result can omit content, supply a string, or contain text, image, document or search_result blocks. A failed or invalid client call can be marked with is_error set to true.

Computer and browser tool members have additional requirements. Dispatch must consider both name and toolset_name, and the result must echo toolset_name. Their result content is limited to text and image blocks, with browser results also permitted one browser_state block; browser tab-management members return only browser_state.

The page also describes more informative error messages, bounded retries and strict: true for schema-conforming tool inputs. It does not establish that a schema-valid call will execute successfully.

Using it

Requirements

Manual handling assumes an existing Claude API integration, tool definitions and application code capable of executing each named client tool. The input passed to a tool is an object corresponding to that tool's input_schema.

The application must retain earlier messages and resend the same tools when continuing the conversation. Authentication setup, installation commands, supported SDK versions and a complete model-compatibility list are not supplied on this page.

Mechanism

For client tools, Claude returns stop_reason set to tool_use and one or more tool_use blocks. The application runs each requested tool, preserves the response's content unchanged as an assistant message, and immediately adds a user message containing one matching tool_result for every client call, including failures. It sends another request with the earlier messages and the same tools, repeating if Claude requests more tools.

Server tools run internally and return their results through the API. A response can nevertheless contain a client call alongside a server call whose result has not arrived. In that case, the continuation user message must contain only the client tool_result blocks. For a server tool Claude called directly, the next response starts with its result block.

The application does not send is_error responses for server tools. Server execution errors arrive inside the server tool's own result block.

Setup

A manual implementation needs a dispatcher that maps requested tool names to executable application functions and converts their outputs or failures into matching results. Computer and browser members require dispatch using toolset_name as well as name.

Message construction needs particular care. No intervening message may separate the assistant's tool-use message from the user's results. Within the user content array, all tool_result blocks must precede any text. If a server tool result remains outstanding, that message must contain results only; the page warns that added text can end the turn early and, for a directly called unresolved server tool, produce a 400 error.

The guide warns that external tool outputs can contain prompt-injection attempts. It recommends keeping this material inside tool_result blocks instead of placing it in system prompts or ordinary user text.

Example

The weather example shows Claude requesting get_weather with location set to San Francisco, CA and unit set to celsius. The application would execute that tool and return a user message containing a tool_result whose tool_use_id matches the original call, with content such as 15 degrees.

For a failed weather request, the page instead illustrates an error message describing an unavailable service and HTTP 500, accompanied by is_error set to true. Claude may then retry or explain the failure. These are illustrative payloads, not evidence of a live weather lookup or successful API execution.

Assessment & evidence

Limitations

The page supplies message examples rather than a complete runnable application. Complete programs, detailed stop-reason handling, parallel tool use, strict tool use and additional prompt-injection protections are linked topics whose contents are outside this page.

Error recovery is conditional: Claude might retry with another tool call, so the application must limit retries. Schema-conforming inputs do not establish execution success, and the page provides no measured recovery rate, latency or security outcome.

The examples were not executed. Compatibility and correctness in a particular application remain unverified.

Reasoning

The guide's practical value comes from connecting concrete message structures to specific failure conditions. Matching identifiers associate outputs with requests; adjacency and ordering rules determine how the next request must be constructed. The unfinished-server-call case explains why adding otherwise permitted text can break a continuation.

These details make it a useful reference for custom orchestration. The page itself recommends the SDK runner when custom execution control is unnecessary, so the choice depends on whether application-specific control justifies maintaining the loop.

Alternatives

The alternative explicitly presented is the SDK tool runner at [https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-runner]. The page describes it as executing tools and returning results automatically, with the linked description also covering loop management, result formatting and retries. Its interfaces, supported SDK versions and operational behavior are not established here.

For readers needing a complete program, the page points to Tutorial: Build a tool-using agent at [https://platform.claude.com/docs/en/agents-and-tools/tool-use/build-a-tool-using-agent]. That tutorial's contents are outside the available evidence.

Evidence

The evidence is the complete documentation page acquired from [https://platform.claude.com/docs/en/agents-and-tools/tool-use/handle-tool-calls.md]. Its front matter identifies the corresponding documentation address as [https://platform.claude.com/docs/en/agents-and-tools/tool-use/handle-tool-calls].

The page directly supports the descriptions of message fields, execution responsibilities, result ordering and error handling. Its payloads illustrate the stated protocol; they do not establish observed runtime behavior, benchmark results or successful deployments.

Access & freshness

Costs

The page supplies no API prices, subscription requirements, free allowances or external tool-service fees. Operating cost is unknown.

It provides no cost comparison between manual handling and the SDK tool runner. Charges associated with requests, retries or connected services would need separate verification.

Rights

The supplied page contains no explicit license, redistribution grant or reuse terms for its prose or examples. Permission to redistribute the documentation or package its examples is unknown; availability at a documentation URL does not establish those rights.

Freshness

The supplied documentation copy was captured on 24 November 2026 at 14:12:00.243 UTC. This is an acquisition timestamp, not a publication or update date.

The page gives no publication date, last-update date or SDK version pin. Its example model identifier does not establish a supported-model list. Changes after the captured copy and compatibility with particular API or SDK versions are unknown.

Actions

Use the guide when custom tool execution requires maintaining your own conversation loop. If that control is unnecessary, consult the SDK tool runner described on the page.

Before deploying a manual implementation, verify successful and failed client calls, multiple calls in one response, result ordering and a continuation with an unfinished server call. Computer and browser integrations also need verification of toolset_name and their narrower result formats.

Keep external content in tool_result blocks, provide useful failure details and bound retries. These are implementation steps supported by the guide; their behavior in your application remains unverified.

Evidence for this report

selected-page.txtselected · checked 2026-11-24