Skip to content
The AI Agent Factory

29.7 Caching by how often content changes

Approved by
Panaversity ·
18 min read

In everyday life. A street cook sells three dishes. Every morning she makes one big pot of base sauce, which goes into every dish all day. For each dish she mixes its own spices once, and keeps them ready. Each order is cooked fresh, because each customer wants something different. She never cooks the base sauce again for a single order. In this section, the base sauce is the tools and the shared rules, and the spice mix is a company's own block. The order is the invoice, and each pot she keeps ready is a cache breakpoint.

What you will learn. You practice this in Lab 29, Task 2.

  • What does the extraction send, block by block?
  • Where do single, layered and rolling breakpoints go?
  • What limits a breakpoint?
  • When does the one-hour cache pay?
  • What breaks the cache?
  • How do you check a breakpoint?

Why it matters. Every invoice resends the same tools and rules. Without a breakpoint, Brightline pays the full input price for them again on every request.

At work. Tuesday, 10:15 a.m. The extraction is the largest line, and little of its input is read from the cache. You open the request the extraction step sends (25.2) and write beside each block how often it changes.

21.12 taught what caching is and the two rules that keep it working: put what never changes first, and never change it between requests. This section adds where to put the markers.

What does the extraction send, block by block?

Two requests for each invoice. The second repeats the first, then adds the invoice. Since Lab 25, the extraction asks for the invoice with the tool get_invoice, and answers after the tool result (Lab 25). These are its blocks:

BlockWhat it holdsHow often it changes
1. ToolsThe definition of get_invoiceWith a new prompt version
2. The system promptThe operator's rules for every invoice, with the five allowed payment termsWith a new prompt version
3. The task turn"Extract INV-8340"For each invoice
Request 1 ends here. The model answers with a get_invoice call.
4. The model's callThe get_invoice call from request 1For each invoice
5. The tool resultThe invoice, as dataFor each invoice
6. A system messageThe run dateEach day
Request 2 ends here. The model answers with the invoice's fields.

The API reads a request from its start: the tools first, then the system prompt, then the turns. A cache hit needs a start that is 100% identical.1

Where do single, layered and rolling breakpoints go?

A breakpoint goes at the end of each block that changes more slowly than what comes after it. A cache_control marker on one block is a cache breakpoint. The API writes everything up to that block to the cache, and a later request that starts the same way reads it.1 Three placements follow from how often the blocks change:

  • Single placement. One breakpoint after the shared rules, block 2. Every invoice of the morning starts with the same tools and rules, so every invoice after the first reads them.
  • Layered placement. A second breakpoint after a block that changes at its own pace. Each company's allowed terms and vendor rules would move into a block of their own, after the shared rules. Brightline's and Cedar Ridge's extractions then share the first layer, and each reuses its own second.
  • Rolling placement. A breakpoint at the end of request 1, on the task turn. Request 2 sends the same blocks with the same markers, so it reads everything request 1 wrote. It pays full price only for the model's call, the invoice and the date.

The run date stays after the last breakpoint. Anthropic's advice is to put text that changes with each request, such as timestamps, after the last breakpoint.2 Section 25.2 already put the date in a system message after the invoice, so no change is needed.

Figure 29.3. Each breakpoint sits where the next block changes faster. Request 2 reads what request 1 wrote.

What limits a breakpoint?

A count, a reach, a minimum length, a price, and timing. The page's own limits:1

  • Four breakpoints a request. Automatic caching, one setting on the request that places a breakpoint for you, uses one of the four. The extraction's three placements fit.
  • A reach of 20 blocks. A breakpoint looks back up to 20 blocks for an earlier write. A run of tool calls, or of tool results, in a row counts as one position. Writes happen only at breakpoints, so looking back finds what an earlier breakpoint wrote, not text that only stayed the same. The extraction's requests are short. A long conversation, such as the month-end review, needs a breakpoint at least every 20 blocks.
  • The minimum length. On Sonnet 5.5 and Haiku 5.5, the part before a breakpoint must be at least 512 tokens. A shorter part is processed uncached, with no error. Read cache_creation_input_tokens on the first request: zero means nothing was written.
  • The price. A five-minute write costs 1.25 times the input price, a one-hour write 2 times. A read costs 0.05 times on Sonnet 5.5, which is $0.10 per million tokens.3 A five-minute entry pays for itself after one read, and a one-hour entry after two.3
  • The timing. "A cache entry only becomes available after the first response starts."1 Requests sent together all miss. Send the morning's first invoice alone, and send the others once its response has started.

When does the one-hour cache pay?

When the gaps between requests are often longer than five minutes, and rarely longer than an hour. A five-minute entry is renewed free each time it is read. A one-hour entry is asked for with "ttl": "1h". Both lifetimes count from the start of the request, and a longer-lived entry must come before a shorter one in the request.1 Anthropic gives a measure. The hour pays when "about 1 turn in 20 follows a pause between 5 minutes and an hour and few gaps run over an hour". It breaks even, neither saving nor losing money, near 1 turn in 30. On Sonnet 5.5, a five-minute entry kept alive by a request every four minutes can cost less.2

The morning extraction sends invoices one after another, so the five-minute entry stays alive. The batch in 29.8 is the other case. Its second round waits for the first to end, so it uses the one-hour cache.

What breaks the cache?

Any change before a breakpoint, and some settings that change nothing in the text. The cache is built in the order tools, system prompt, messages, and a change breaks its own level and every level after it:1

ChangeWhat it breaks
The tool definitionsEverything
Turning web search or citations on or off, or the speed settingThe system prompt and the messages
tool_choice, or adding or removing an imageThe messages
The thinking settingsThe messages, and on some models the tools and system prompt too
Top-level effortIt "can invalidate all or part of the prompt cache". Setting it to the model's default does not.4 A per-message effort change, in beta, keeps the cached start5
Thinking blocks dropped from earlier turnsThe messages
The task budget's value (29.9)Entries made under the old value no longer match6
The modelEverything. "The cache is per-model"7

So never switch the model, the tools or the thinking settings in the middle of a conversation you want cached. A request on Haiku 5.5 reads nothing that Sonnet 5.5 wrote.

How do you check a breakpoint?

By the cache share and the usage fields, never by the suite. A breakpoint changes what a request costs, not the text the model reads, so the output cannot change because of it. Running Chapter 24's suite would spend money to measure nothing. Rerun one day's invoices with the breakpoints, then read three things:

  1. The first request writes: cache_creation_input_tokens is above zero.
  2. The requests after it read: cache_read_input_tokens is above zero, and the cache share rose.
  3. If the share did not rise, cache diagnostics names the earliest change (29.6).

At 10:15 you add one breakpoint after the tools and rules, and one at the end of each first request. A rerun of Monday, May 3's invoices raises the extraction's cache share. The suite is not run.

The operating rule: place a breakpoint wherever the next block changes faster, keep per-request text after the last one, and check it by the cache share.

Check yourself

Question 1 / 6

0 answered

Where does the single breakpoint go on the extraction's requests?

  1. Prompt caching, Anthropic, read November 30, 2026.↑↑2↑3↑4↑5↑6
  2. Optimizing for cost and intelligence, Anthropic, read November 30, 2026.↑↑2
  3. Pricing, Anthropic, read November 30, 2026.↑↑2
Owner
Panaversity