2026-12-06: Are you caching things nobody will read?
These are my notes from Lumer et al. (PwC), "Don't Break the Cache: An Evaluation of Prompt Caching for Long-Horizon Agentic Tasks" (arXiv:2601.06007v2, 31 Jan 2026).
The paper starts from the observation that agents make many API calls with a context that keeps growing, and that the value of provider prompt caching for this kind of work had not been measured. It compares ways of deciding what gets cached, across OpenAI, Anthropic and Google, on a web research agent.
The headline claim in its abstract: caching "reduces API costs by 41-80% and improves time to first token by 13-31%". It also says naive full-context caching can increase latency.
Here is the question I want to answer. An agent has a 10,000-token system prompt and calls a search tool again and again. On every call it sends everything so far. Should it ask for all of it to be cached, or only the part that never changes?
The playground: one HTML page, no install, no API key: prompt-caching-playground. You move the cache boundary and watch reads, writes and cost. It is a simulation, with its assumptions listed on the page.
Words used below
KV cache: the keys and values the model computes for every token it reads, kept so they are not computed again.
Prefill: the model reading the prompt and building that KV cache.
Prefix: the prompt from its first token up to some point.
Prompt caching: a provider keeping the work done for a prefix and reusing it in a later API call.
Cache write / cache read: storing a prefix / reusing a stored one. Reads are billed below the normal input price. Some models charge writes above it.
Cache miss: the part of a prompt that found no stored match, so it is computed again.
Cache boundary (breakpoint): the point up to which you want the prompt cached.
TTL (time to live): how long a stored entry lasts.
TTFT (time to first token): the wait from sending the request to receiving the first piece of the answer.
The bookmarked binder
Picture someone who must read a binder from page one before answering each question. To save time they pencil notes in the margins. A note on page 40 depends on everything on pages 1 to 39.
Add pages at the back, and every old note is still good. Read only the new pages. Change a line on page 1, and every note after it is invalidated. Start over.
The notes are the KV cache. In the models behind these APIs, a token attends only to the tokens before it, which is why appending is harmless and an early edit is not. I wrote about this in how coding agents reuse KV states across turns.
Prefix matching
The paper states the rule plainly (Figure 5): a hit needs the prefix to match exactly. Matching is not about finding similar text somewhere in the prompt. It starts at the first token and stops at the first difference.
Figure 5 from Lumer et al. (2026), CC BY 4.0. A matching prefix is reused; a difference in the first token loses everything. Rendered as an image from the arXiv HTML version; caption is mine.
request 1: [system prompt][question][tool call 1][result 1]
request 2: [system prompt][question][tool call 1][result 1][tool call 2][result 2]
<------------------ can be reused ------------->
request 2 with a new timestamp on line one:
[timestamp!][system prompt][question] ... <- nothing can be reused
Docs
How you get a hit differs by provider.
Anthropic: you opt in with cache_control, either once for the whole request or on chosen blocks, with up to 4 breakpoints. The prompt is ordered tools, system, messages. From each breakpoint it looks back at most 20 block positions for an earlier write.
OpenAI: caching works without opting in. GPT-5.6 and later also let you place breakpoints explicitly.
Gemini: implicit caching is on by default for 2.5 and newer models, with no storage fee or write surcharge. Some models also offer explicit caches through a separate API.
Every provider also has a minimum length. The paper's Table 4 lists 1,024 tokens for GPT-4o, GPT-5.2 and Claude Sonnet 4.5, and 4,096 for Gemini 2.5 Pro. Current docs differ by model (for example 512 for Claude Sonnet 5.5, 1,024 for GPT-5.6 and later, 4,096 for Gemini 3 and 4 models), so check the one you use.
The four cache modes
The paper. The agent is built with Deep Agents and runs tasks from DeepResearch Bench, with a 10,000-token system prompt and a web search tool. The models are GPT-5.2, Claude Sonnet 4.5, Gemini 2.5 Pro and GPT-4o. Each model and mode gets 40 sessions, each on a different research question, after warm-up calls.
The authors control the boundary with UUIDs, random IDs that never repeat, so nothing from a UUID onwards can match an earlier request.
- No cache (baseline): start of the system prompt - nothing can be reused
- Full context: nowhere - turn caching on and leave it alone
- System prompt only: right after the system prompt - cache just the stable part
- Exclude tool results: after the system prompt and after each tool result - keep tool results out of the cache
If matching is strictly by prefix, the first UUID, the one after the system prompt, already ends what can be reused. The paper's own Figure 9 shows only the system prompt as cached in that mode. The authors say they needed the extra UUIDs because providers handle KV caching differently, and that explicit boundaries behave more predictably.
Figure 8 from Lumer et al. (2026), CC BY 4.0. System prompt only. Rendered as an image from the arXiv HTML version; caption is mine.
Figure 9 from Lumer et al. (2026), CC BY 4.0. Exclude tool results. In both, only the system prompt is drawn as cached. Rendered as an image from the arXiv HTML version; caption is mine.
One run, worked by hand
A made-up run, not the paper's. System prompt 10,000 tokens, question 200. Three tool calls, so four requests. Each tool call is 300 tokens of assistant message plus a 2,000-token result.
Prices are the paper's Claude Sonnet 4.5 prices per million tokens: $3.00 input, $0.30 cache read, $3.75 cache write. Output is left out.
The four requests are 10,200, 12,500, 14,800 and 17,100 tokens long: 54,600 in total.
No cache. 54,600 x $3.00 per million = $0.1638.
System prompt only. Request 1 writes the 10,000-token system prompt. Requests 2 to 4 read it. Everything else is plain input.
| request | read | write | plain | cost |
|---|---|---|---|---|
| 1 | 0 | 10,000 | 200 | $0.0381 |
| 2 | 10,000 | 0 | 2,500 | $0.0105 |
| 3 | 10,000 | 0 | 4,800 | $0.0174 |
| 4 | 10,000 | 0 | 7,100 | $0.0243 |
| total | 30,000 | 10,000 | 14,600 | $0.0903 (44.9% less than no cache) |
Full context. The boundary follows the end of the conversation.
| request | read | write | plain | cost |
|---|---|---|---|---|
| 1 | 0 | 10,200 | 0 | $0.0383 |
| 2 | 10,200 | 2,300 | 0 | $0.0117 |
| 3 | 12,500 | 2,300 | 0 | $0.0124 |
| 4 | 14,800 | 2,300 | 0 | $0.0131 |
| total | 37,500 | 17,100 | 0 | $0.0754 (54.0% less than no cache) |
The simulation, full context, last request. Green is read, amber is written.
There are two interesting things here:
- A write costs $0.75 per million more than plain input here, and one later read saves $2.70 per million. One reuse more than pays for it.
- The 2,300 tokens written in request 4 are never read, because there is no request 5. A write pays off only if a later request reads it. The paper makes the same point in its discussion of tool calls.
In this toy run full context wins on cost. That is not what the paper measured, where the two were close and system prompt only was slightly ahead for GPT-5.2 and Claude. My simulation assumes that all history is appended unchanged and read back perfectly. It cannot reproduce provider behaviour, so treat it as a way to see the mechanics.
Results
The paper, Table 2. Reduction against no cache, in percent, written as cost / TTFT. A negative number means slower.
| Model | Full context | System prompt only | Exclude tool results |
|---|---|---|---|
| GPT-5.2 | 79.3 / 9.5 | 81.4 / 10.5 | 79.6 / 13.0 |
| Claude Sonnet 4.5 | 77.8 / 21.8 | 78.5 / 22.9 | 78.1 / 20.9 |
| Gemini 2.5 Pro | 38.3 / 6.0 | 41.4 / 6.1 | 27.8 / -2.9 |
| GPT-4o | 47.8 / -8.8 | 45.9 / 30.9 | 46.8 / 28.1 |
Redrawn from Table 2 of Lumer et al.
Cost went down in every cell. The authors attribute most of it to the large, stable system prompt, and note that history and tool calls were small next to it in their setup.
Latency is less tidy. Full context made GPT-4o 8.8% slower, while the other two modes made it about 28-31% faster. Exclude tool results made Gemini 2.9% slower. Claude improved by 20.9-22.9% in all three.
The cheapest mode is not always the fastest. On GPT-5.2, system prompt only saved the most money (81.4%), and exclude tool results had the best TTFT (13.0%).
The paper's "likely explanation" for full context doing worse on latency is that it triggers cache writes for tool calls and results that add overhead. It does not isolate that cause in a separate experiment, and I did not find an explanation for Gemini's gap between modes.
The headline numbers do not all agree
I checked the summary figures against the tables.
| Statement in the paper | TTFT | Cost |
|---|---|---|
| Abstract, introduction, conclusion | 13-31% | 41-80% |
| Section 4.1 | 6-31% | 41-80% |
| Table 1 (labelled best mode per model) | 6.1-30.9% | 41.4-79.6% |
| Figure 1 (labelled best mode per model) | 13.0-30.9% | 45.9-79.6% |
6-31% is the range that matches Table 1. Its low end is Gemini's 6.1%. The 13-31% range matches Figure 1. Figure 1 and Table 1 disagree on Gemini 2.5 Pro. Figure 1 shows 52.2% cost and 13.1% TTFT. Table 1 shows 41.4% and 6.1%, and no mode in Table 2 gives the figure's pair. The other three models match. The figure looks the same in v1 and v2 of the paper. I use the tables above.
"Best mode" has no single definition. For GPT-5.2 and GPT-4o, Table 1 lists the mode with the best TTFT, not the lowest cost. The 41% floor is a best-mode number. Across all modes the lowest cost saving is Gemini's 27.8%.
Figure 1 from Lumer et al. (2026), CC BY 4.0. Compare the Gemini 2.5 Pro bars with Table 1. The authors' image, unchanged; caption is mine.
So a figure like "13-31% faster" needs its model and mode attached.
Size matters
The paper's ablation varies the prompt size from 500 to 50,000 tokens and the number of tool calls from 3 to 50, on GPT-4o, GPT-5.2 and Claude Sonnet 4.5. At 50,000 tokens it reports cost savings of 89% (GPT-5.2), 88% (Claude) and 54% (GPT-4o).
At 500 tokens, below the caching minimum, TTFT got 10-18% worse, which the authors put down to server variance. It also reports cost savings of 10-45% at small sizes, including 500, and I could not tell from the text how a prompt below the minimum saves money.
Savings stayed fairly stable as tool calls increased.
What breaks a cache
The paper names these:
- Changing values in the system prompt: timestamps, date strings, session IDs, user information. If you need them, put them at the end of the system prompt.
- Changing tool definitions, for instance when tools are discovered at run time through MCP. The authors suggest a fixed set of general-purpose functions, with new capabilities done through generated code.
- Summarising or pruning old tool calls. It rewrites history, so what was cached no longer matches.
Provider documentation adds a few more invalidation condition. On OpenAI the list includes changing the model, the tools, the output format or the reasoning effort. On Anthropic, changing tool definitions invalidates the whole cache, and some other settings invalidate parts of it. On Gemini, reordering tools or changing the thinking level breaks the match.
"At the end of the system prompt" still needs care with explicit breakpoints. Anthropic's docs advise putting the breakpoint at the end of the static part, not on the block that varies.
My read of the paper and the docs: a UUID alone only stops reuse. It does not stop a write. The paper keeps changing content out of what gets reused, and on newer models you can also keep it out of what gets written.
On OpenAI's GPT-5.6 and later, the default (implicit) mode places a breakpoint at the latest eligible message. To avoid paying to write a part that keeps changing, put an explicit breakpoint at the end of the stable content and switch to explicit-only mode. Earlier OpenAI models have no separate write charge.
The same four-request simulation, this time across four machines: put a changing value anywhere in the system prompt and leave one boundary at the end of the conversation. Every request writes everything and reads nothing: $0.2047, 25% more than not caching at all.
The simulation. The white marker is the changing value.
Misses and writes
One of my questions while reading this paper was: what is the cache miss strategy? The unmatched part is computed again, as normal input. Whether it is then stored is a separate matter: it has to be long enough, and caching has to be set to write there.
What a write costs depends on the provider and model.
| Write price | Read price | How long it lasts | |
|---|---|---|---|
| Paper, Claude Sonnet 4.5 (Jan 2026) | 1.25x input | 0.1x | not given per provider |
| Paper, GPT-5.2 and GPT-4o | none listed | 0.1x and 0.5x | not given per provider |
| Anthropic docs | 1.25x for 5 minutes, 2x for 1 hour | 0.1x, lower on some newer models (0.05x on Sonnet 5.5) | 5 minutes by default, refreshed on use; 1 hour optional |
| OpenAI docs, GPT-5.6 and later | 1.25x for 30 minutes on the models I checked; a 12-hour option costs more | depends on model (0.05x on GPT-6.2 Sol) | 30 minutes by default |
| OpenAI docs, GPT-5.5 and earlier | no separate write price | depends on model | depends on model and settings |
| Gemini docs, implicit | no write surcharge | 95% off on Gemini 4, up to 90% off on Gemini 3 and 2.5 | best effort, up to 24 hours in memory |
Pricing has changed since the paper was published: its Table 3 lists no write price for OpenAI, and current OpenAI docs charge one on newer models. Overall, the paper puts TTLs between 5 minutes and 24 hours.
Sharing across requests
I also wanted to understand how KV blocks are shared across requests. The paper does not cover this. It also measures benefit inside one conversation at a time, not across sessions.
Docs: vLLM, an open-source serving engine, describes its automatic prefix caching like this: KV cache is held in fixed-size blocks, the idea from PagedAttention. Each full block is identified by a hash of its own tok
Comments
No comments yet. Start the discussion.