ByteCosts
anthropic-cache-breakpoints-guide.mdx

AI Coding Agents

Anthropic cache_control breakpoints guide for tool loops

Place Anthropic cache_control breakpoints where a reusable prefix ends, such as the last tool, the last stable system block, a saved conversation checkpoint, or the latest cacheable block in an append-only loop. Each breakpoint looks back at most 20 positions on the Claude API, so keep an earlier marker when a long turn can push the last write out of reach.

Place Anthropic cache_control breakpoints where a reusable prefix ends, such as the last tool, the last stable system block, a saved conversation checkpoint, or the latest cacheable block in an append-only loop. Each breakpoint looks back at most 20 positions on the Claude API, so keep an earlier marker when a long turn can push the last write out of reach.

Choose a boundary for each kind of reuse

On the Claude API, prefixes include tools, then system, then messages. A marker at the system boundary covers the tools too. A marker in the history covers everything before it. Each write saves an entry at the marked endpoint, so several markers let future requests find a smaller matching prefix when a later section has changed. The request can have up to four breakpoints as of November 30, 2026. Use fewer when your workload has fewer useful boundaries. Anthropic prompt caching

When you mix lifetimes, place every 1-hour marker before any 5-minute marker. If the request already has a cache_control marker and Claude runs a server tool such as web search, the API also marks the server tool result with its own 5-minute breakpoint. Those writes can appear under usage.cache_creation.ephemeral_5m_input_tokens even when all your markers request an hour. Anthropic prompt caching · Tool use with prompt caching

Candidate breakpointWhere to put itWhen keeping it pays off
End of toolsOn the last tool in the fixed tool array.Tools stay identical across requests that use different system instructions.
End of systemOn the last stable system content block.Fixed operating instructions and tools are reused across different questions or histories.
Conversation anchorOn a stable history block where you have written, or plan to write, a reusable prefix.A batch of new blocks may push the advancing breakpoint too far from the last write.
Advancing tailOn the latest eligible content block whose prefix will be replayed on the next request.A long agent loop adds tool results and assistant turns between user messages.

Ask which subsequent requests can actually use a boundary before spending a slot. If tools and system instructions always travel together, a marker at the system end is often sufficient. If several workflows share tools but vary system instructions, the end-of-tools entry may be useful on its own. Anthropic documents that the marker on an mcp_toolset entry applies at the end of that expanded toolset. A tool declared with defer_loading: true cannot also carry a cache marker, so place the tool breakpoint on a suitable non-deferred definition. Tool use with prompt caching · Tool search

Place a fixed boundary before content that changes on every request. If you put the only breakpoint on a block that includes a different timestamp each time, the hashes at those writes differ. Lookup may inspect the stable blocks ahead of the timestamp, but it has no entry to read there unless an earlier call wrote one. Move the marker to the last stable block and confirm a write at the new boundary before testing a read.

Count positions from the newest marker backward

The API checks up to 20 positions per breakpoint, including the breakpoint itself. On the Claude API, a consecutive run of tool_use blocks counts as one position, and a consecutive run of tool_result blocks counts as one position. Parallel calls collected into a single run can therefore have a smaller effect on lookup than the raw number of blocks suggests. Alternating tool and result runs or intervening text blocks can still use more positions. Count the blocks in the provider request, applying the run rule, before deciding that a loop has exhausted the window. Anthropic prompt caching

Suppose an illustrative tool loop writes at effective position 12. Assume that entry is still warm, the next request preserves its prefix and the added blocks follow it. If the next marker lands at position 31, the API can inspect positions 31 through 12. If the next request jumps directly to position 32 instead, it can inspect positions 32 through 13. The write at 12 is just outside this second window even with identical content through that point.

You can handle the jump by keeping an intermediate marker at position 12 while advancing the tail to position 32. With the earlier entry already written, that additional lookup can reach it. Keep a stable checkpoint before sending the batch you expect to expand the prompt, then advance the tail once the results are in. If you discover a stable anchor that was never written, mark it to seed a future read. A new marker cannot retroactively create a hit on that request.

A stopped breakpoint has a different signature from a lookback miss. When the only marker stays on the last user text, the loop’s later tool content never becomes part of a new marked prefix. A read at the original user boundary can remain steady while the uncached suffix gets larger on each step. Advancing that marker through reusable tool results lets the next request seek the previous tail. Preserve an earlier checkpoint when that seek could exceed the window.

Build a request with explicit markers

This illustrative Claude API Messages body shows a tool continuation with four markers. The last marker is on the result you send after Claude calls read_project_note. The sample strings are short to make the placement visible. Substitute actual reusable content and confirm that each marked prefix you intend to use meets the chosen model’s minimum before expecting cache reads.

{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "tools": [
    {
      "name": "read_project_note",
      "description": "Read a project note by name.",
      "input_schema": {
        "type": "object",
        "properties": { "name": { "type": "string" } },
        "required": ["name"]
      },
      "cache_control": { "type": "ephemeral" }
    }
  ],
  "system": [
    {
      "type": "text",
      "text": "Use project notes to explain the deployment workflow.",
      "cache_control": { "type": "ephemeral" }
    }
  ],
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Use the staging rollout note to explain the rollback checks.",
          "cache_control": { "type": "ephemeral" }
        }
      ]
    },
    {
      "role": "assistant",
      "content": [
        {
          "type": "tool_use",
          "id": "toolu_01",
          "name": "read_project_note",
          "input": { "name": "staging-rollout" }
        }
      ]
    },
    {
      "role": "user",
      "content": [
        {
          "type": "tool_result",
          "tool_use_id": "toolu_01",
          "content": "Confirm the previous staging deployment is available and passes its smoke checks.",
          "cache_control": { "type": "ephemeral" }
        }
      ]
    }
  ]
}

On a later append-only turn, replay the assistant tool call and its result, then move the final marker to the newest eligible block you expect to replay. Retain any earlier anchors you still need. The new marker can find the write at toolu_01’s result if that entry is warm and still inside the lookback window. Thinking blocks may be cached along with surrounding history, but cannot carry an explicit marker themselves. Empty text blocks and nested sub-content such as citations are also ineligible as direct targets. When the newest input is a one-off question and you want to cache a shared reference only, leave the tail after the final stable marker. Anthropic prompt caching

The model-specific minimum is measured on the prefix you want to cache. Anthropic lists these tiers for the Claude API, Claude Platform on AWS, Google-managed Claude Models on Google Cloud, and Microsoft Foundry, where each model is available.

MinimumExample models at this tier
512 tokensClaude Sonnet 5.5, Opus 5.5, Haiku 5.5, Fable 5.2
1,024 tokensClaude Opus 4.8, Sonnet 5, Sonnet 4.6
2,048 tokensClaude Opus 4.7, Mythos Preview
4,096 tokensClaude Opus 4.6, Haiku 4.5

A request under the threshold can succeed with no cache write. Check usage.cache_creation_input_tokens and usage.cache_read_input_tokens together. If both are zero, check the threshold and the actual wire markers. After a confirmed eligible write, send a follow-up while the entry is warm and compare the read against the expected prefix. Track usage.input_tokens to see how much input was outside the cache read and write. Anthropic documents these as separate counters. Anthropic prompt caching

Run the first verification pair in sequence. Anthropic says the entry becomes available after the first response starts, so simultaneous requests can miss an eligible breakpoint that has yet to become readable. Once the sequential pair shows reuse, repeat with a change confined to the last message. The earlier marked history can still hit if it matches, and the new tail can be written. Then change the system instructions and repeat with the tools held fixed. If you wrote an eligible tools entry, that is the earlier read you are testing for. Comparing these cases gives you two independent checks on the placement before adding request concurrency. Anthropic prompt caching

Use automatic caching for an append-only tail

With automatic caching, add "cache_control": {"type": "ephemeral"} at the request’s top level. The API selects the last cacheable block and advances the breakpoint as history grows. If the final block is ineligible, it searches backward for an eligible target. The same lookback and minimum-length rules still apply. On Amazon Bedrock’s bedrock-runtime endpoint, top-level automatic caching returns a 400 error. Use explicit cache breakpoints there. Anthropic prompt caching

You can combine an automatic tail with explicit anchors. Reserve a slot for it. Four explicit markers already consume the limit and adding the top-level setting produces a 400 error. If the last block already has an explicit marker with the same TTL, automatic caching does nothing. If that marker has a different TTL, the API returns a 400. Explicit markers also give you direct control when a changing final block would otherwise attract the automatic marker on every request.

Check tool continuations the way Cline’s reports did

Cline issue #15167, opened October 18, 2026 and still open as of November 30, 2026, reports that the Anthropic provider’s only breakpoint stayed on the last text block of the last user-role message. The reporter captured a request with assistant tool calls and tool results after that point. During the autonomous loop the client replayed the growing tail, while the only marker remained at the initial prompt. Cline issue #15167

Two open PRs describe different proposed changes as of November 30, 2026. PR #15174, opened October 18, moves the explicit marker to the latest eligible tool result on the applicable Anthropic serialization path. PR #15340, opened October 25, describes fixing the request-level option mapping so the adapter emits top-level cache_control and automatic caching can advance the tail. The author of PR #15340 measured a flat 3,359 tokens read on each of three tool continuations before the change and reads of 3,361, 6,548 and 9,736 tokens after it. Test your own adapter at the outgoing request boundary. Check the initial prompt and consecutive tool continuations without a new human message. You should be able to see where the cache was written on the first call and which new blocks the next call adds to that write. Cline PR #15174 · Cline PR #15340

Pick a layout and verify the next read

  • Use one explicit breakpoint if the same reference material precedes independent, changing questions.
  • Use automatic caching on a supported path if the request grows by appending blocks that you want to reuse. Test actual tool continuations with the agent caching guide.
  • Keep an explicit intermediate anchor if a long step can push the previous write outside the lookback. If the old write is in reach, inspect silent cache busters and compare the pair with Claude cache diagnostics.
  • Check whether the entry is still warm at the start of the next request. Use the 5-minute versus 1-hour TTL comparison to decide how long to retain a stable prefix.

Sources

How this note was produced

Drafted with AI assistance from committed ByteCosts pricing snapshots and deterministic cost formulas. Figures are grounded in the linked sources (last updated 2026-11-30). Read our editorial & automation policy, inspect the methodology, or report a discrepancy.

Anthropic cache_control breakpoints guide for tool loops. ByteCosts. Updated 2026-11-30. https://bytecosts.com/blog/anthropic-cache-breakpoints-guide/

Sources