Learning resourcesReviewed · Anthropic

Tool use with prompt caching

This Claude API guide helps developers reuse cached tool definitions, with the main catch that changes to tools and request settings can invalidate cached content. It explains cache_control placement, deferred tool loading, toolset boundaries and automatic caching of server-tool results.

Researched 25 Nov 2026

In short.

This Claude API guide is for developers building tool-using assistants, with the main catch that cache reuse depends on which request content and settings change. It explains where to place cache_control markers, how deferred tool discovery preserves the cached prefix, and which changes invalidate tool, system or message caches. It also documents automatic five-minute caching of server-tool results when prompt caching is already enabled. Prices, minimum cacheable lengths and a model compatibility matrix are absent, and no behavior or performance was tested.

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

Covers the complete selected page at [https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-use-with-prompt-caching.md], including the request fragment, toolset and batch notes, deferred loading, invalidation rules, automatic server-result caching, per-tool table and next-step references. Linked pages are excluded. No code or API requests were executed, and performance, prices and model compatibility were not independently assessed.

The overview

Resource identity

Tool use with prompt caching is a documentation guide on Claude's developer platform. The source address is [https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-use-with-prompt-caching.md]. It teaches a specific API feature rather than providing a standalone application or installable library.

Its focus is caching tool definitions across conversation turns, preserving that cache during tool discovery, and understanding invalidation. General prompt caching is delegated to a separate linked guide.

Practical assessment

The guide is useful when an assistant repeatedly sends the same tool definitions or discovers additional tools during a conversation. Its concrete request example and invalidation tables help developers identify where cached content can remain reusable.

It is a focused implementation reference, not a complete introduction to the Claude API. Developers making a cost or compatibility decision still need information that this page does not supply, including pricing, cache eligibility thresholds and supported model details. Actual savings and reliability are not assessed.

Who it helps

The primary audience is developers maintaining Claude assistants with repeated tool calls, large tool collections, MCP toolsets or server tools such as web search. Developers investigating unexpected cache misses can use the tables to connect request changes with the affected cache level.

Beginners can follow the small weather-and-time example, but should understand that a tool definition describes an operation and its accepted inputs. Reading this page alone does not teach authentication, tool execution or a complete conversation loop.

What the guide explains

The page explains how to cache a sequence of tool definitions, place markers on MCP, computer-use and browser-use toolset entries, and handle markers within batch actions. It also describes how defer_loading and tool search preserve the existing cached prefix.

It maps request changes to cache invalidation, explains automatic server-tool-result caching, and identifies relevant usage accounting. Its per-tool table distinguishes prompt caching from code-execution container state and notes that text editor, Bash and memory tools have no special caching interaction.

Using it

Requirements and dependencies

Following the configuration example requires control over the tools array in a Claude API request. The described automatic caching of server-tool results requires the request to contain at least one cache_control marker.

The deferred-loading pattern involves defer_loading and discovery through tool search. The strict-mode discussion concerns grammar construction, while the MCP and computer/browser instructions apply to their respective toolset entries.

The page does not establish required SDK versions, authentication setup, minimum cacheable token counts or a complete list of supported models. Some effects of thinking and effort settings explicitly depend on the model.

How caching works

A cache_control marker on a tool establishes a breakpoint: the cached tool-definition prefix extends from the first tool through the marked tool. The cache hierarchy is tools, then system content, then messages. A change at one level invalidates that level and everything after it.

Deferred tools are excluded from the system-prompt prefix. When tool search discovers one, its definition appears in conversation history as a tool_reference block, leaving the earlier prefix unchanged. The page separately states that strict-mode grammar construction uses the full tool list regardless of deferred loading, preserving grammar caching during dynamic loading.

With prompt caching enabled, the API automatically adds a breakpoint to a server-tool result before the next iteration within the same request. This allows subsequent iterations to reuse the growing prefix.

Configuration guidance

For ordinary tool definitions, place cache_control: {"type": "ephemeral"} on the last tool in the tools array to cache the entire tool-definition prefix. Reusing that prefix depends on keeping the relevant definitions unchanged.

For mcp_toolset, place the marker on the toolset entry; the API applies it to the final expanded tool because you do not control the internal tool order. Computer-use and browser-use toolsets also take the marker on the toolset entry, not inside a member's configs entry.

Within a batch action, a marker on a member tool_use or tool_result block takes effect at the end of the batch. Multiple markers in that batch act as one breakpoint but each counts toward the four-marker request limit, so the page advises using at most one in any turn.

Concrete example

The supplied JSON fragment defines get_weather with a required location string and get_time with a required timezone string. Only get_time, the second and final tool, carries cache_control: {"type": "ephemeral"}. That placement makes the cached prefix include both tool definitions.

The fragment demonstrates marker placement. It does not include a complete API request, tool implementations, a response or cache-hit measurements, and it was not executed.

Assessment & evidence

Limits and failure points

Changing tool definitions invalidates all three cache levels. Toggling web search or citations invalidates system and message caches; the per-tool table also assigns that effect to enabling or disabling web fetch. Changes to tool_choice, disable_parallel_tool_use or image presence invalidate the messages cache.

Changing thinking parameters always invalidates the messages cache and can also invalidate tool and system caches on models that render those settings earlier. Changing output_config.effort can affect messages and, on some models, earlier levels too. Sending the default effort explicitly is equivalent to omitting it.

The page does not give exhaustive cache eligibility rules or measured outcomes. Prompt-cache reuse also says nothing about code-execution container state, which the page identifies as independent.

Why these details matter

The prefix hierarchy explains why editing a tool schema has a broader effect than changing tool_choice: the schema occurs earlier in the cached request structure. A practical implication is to keep frequently reused definitions stable and examine later settings when diagnosing message-cache misses.

Deferred discovery offers a documented way to add tools to the conversation without rewriting that earlier prefix. This makes the guide particularly relevant to assistants with many available tools, although the evidence does not quantify the benefit for any workload.

The distinction between explicit marker lifetimes and automatic five-minute server-result writes helps explain usage responses that contain more than one cache lifetime.

Related approaches

The page describes caching always-loaded tools and combining a smaller always-loaded set with tools discovered on demand. The latter preserves the existing prefix when discovered definitions are added to conversation history.

For broader background, it links to Prompt caching at [https://platform.claude.com/docs/en/build-with-claude/prompt-caching] and Tool search tool at [https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool]. Those pages are outside the assessed scope. No competing providers or alternative caching products are compared.

Evidence and confidence

The evidence is the complete selected Claude documentation page, including its JSON fragment, invalidation table, per-tool table and explanatory notes. It supports statements about documented configuration and intended API behavior.

It contains no observed API responses, benchmarks or execution results. Cache-hit behavior, savings and compatibility in a particular application remain untested.

Access & freshness

Costs and accounting

API prices, cache read/write rates and monetary savings are unknown from this page. It points to the general prompt-caching guide for pricing, but that linked content is outside the available evidence.

Automatic server-tool-result breakpoints use the default five-minute time to live, independently of the lifetime chosen for your own markers. Those writes appear in response usage under cache_creation.ephemeral_5m_input_tokens. Five-minute writes can therefore appear even when all explicit markers use a one-hour lifetime; the page provides no prices for either lifetime.

Rights and reuse

The supplied page contains no explicit license or redistribution grant for its prose or JSON example. Permission to redistribute the complete documentation or package its contents is therefore unknown.

The page also does not establish Claude API contractual terms or data-handling terms. Cache lifetime information alone does not establish those terms.

Freshness and version limits

The available documentation snapshot was captured on 25 November 2026 at 01:23:00 UTC. The page text supplies no publication date, last-updated date, SDK version or named model version.

Its model-dependent qualifications for thinking and effort settings limit how broadly those rules can be applied. Changes after the snapshot and compatibility with any particular model version are unknown.

Suggested next steps

For an existing integration, identify the tool definitions reused across turns and place the marker at the appropriate tool or toolset boundary. If tools are discovered dynamically, use the deferred-loading guidance to avoid changing the earlier prefix.

When investigating misses, compare request changes against the documented hierarchy, including tool definitions, tool_choice, parallel-tool settings, image presence, thinking and effort. If tool_choice must vary during a conversation, the page suggests placing breakpoints before the variation point.

Before estimating savings, obtain pricing and cache eligibility details from the broader documentation. In your own validation, inspect response usage for automatic five-minute writes. These are proposed implementation steps; no API calls or tests were performed.

Evidence for this report

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