Prompt Caching for Coding Agents Is Worth It, but a Prompt Cache Can't Be Shared Across Models
On list prices, caching cuts a 100-request Opus 5.5 session's bill by about 90 percent. Switching models mid-session, by /model or opusplan, starts a new cache, and no hosted API lets one model read another's KV cache.
Prompt caching is worth it for coding agents: on Anthropic's list prices, a 100-request Claude Opus 5.5 session that would cost about $53.60 with no caching costs about $5.67 with it, because every request after the first rereads the earlier context at a twentieth of the input price. But a prompt cache cannot be shared across models. Anthropic's Claude Code docs say "each model has its own cache," and no provider, Anthropic, OpenAI or Amazon Bedrock, documents a way for one model to read another's cached state. The practical way to "share" work across models is a short handoff to a subagent, not the cache itself.
What a prompt cache actually stores
A coding agent resends its whole context on every request: the system prompt, the tool definitions, project files such as CLAUDE.md, and every earlier message and tool result. Claude Code's documentation describes the pattern plainly: new content is appended at the end, "which means most of each request is identical to the one before it." Caching lets the provider skip reprocessing that identical start, the prefix.
What gets skipped is the expensive part of reading a prompt, the prefill, in which the model computes key and value tensors (the K/V cache) for every token at every layer. Those tensors are produced by one model's weights. They are not text, and they mean nothing to a model with different weights. That is why the rule in Claude Code's docs is absolute: "Switching models recomputes the entire request even when the content is identical." The same docs say two requests share a cache only when their model, speed and prefix all match.
The match must also be exact. Anthropic's API docs require "100 percent identical prompt segments," processed in the order tools, then system prompt, then messages, so a change early in the request invalidates everything after it. Amazon Bedrock's documentation describes the same chain. OpenAI's guide says reuse "requires the entire rendered prefix to match." OpenAI's guide does not say whether a cache can carry from one model to another; it does say caches live on individual machines and are never shared across organizations.
Why caching pays back almost immediately
The pricing is built around reuse. Anthropic charges 1.25 times the base input price to write a five-minute cache entry and 2 times for a one-hour entry; reads cost 0.1 times, or 0.05 times on Opus 5.5 and Sonnet 5.5. OpenAI's GPT-5.6 and later charge 1.25 times for its 30-minute default, 2.5 times for 12 hours, and 0.1 times to read.
The break-even follows from those multipliers. Send a prefix P twice: uncached, that is 2P. With Anthropic's five-minute cache it is 1.25P plus 0.1P, or 1.35P, so caching wins on the second request. The one-hour cache costs 2.1P for two requests, slightly more than not caching, and wins from the third (2.2P against 3P). OpenAI's 30-minute tier breaks even the same way as Anthropic's five-minute one, and its 12-hour tier from the third request.
The choice between lifetimes depends on how you work. The one-hour write costs an extra 0.75P. Under the five-minute cache, one idle gap of more than five minutes forces a full rewrite at 1.25P instead of a read at 0.1P. On a stable prefix, one coffee break an hour pays for the longer lifetime; continuous bursts of work never use it. Claude Code already makes this choice for subscribers: its docs say the main conversation gets the one-hour cache on a Claude subscription within plan usage, and five minutes on an API key or a cloud provider, which the promptCacheTtl setting can change.
An agent loop sends dozens to hundreds of requests on a growing prefix, so it is far past break-even within minutes. In an April 30, 2026 post, Thariq Shihipar of the Claude Code team wrote that the team runs alerts on hit rate and declares incidents when it drops, because "a few percentage points of cache miss rate can dramatically affect cost and latency."
Where the cache breaks: switching models
Model switches are easier to trigger than they look. Claude Code's docs list /model, automatic model fallback, a skill or command whose frontmatter names a different model, and the opusplan setting, which runs Opus in plan mode and Sonnet in execution, "so each plan-mode toggle is a model switch and starts a fresh cache." On most models, changing effort level also starts a new cache, though the docs say Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.1 and later keep it when you sign in with an API key or a Claude subscription. Fast mode keeps a separate cache from standard speed.
What a switch costs depends on context size and on which model you move to. At 100,000 tokens of context, the next request on Opus 5.5 rereads the history for about $0.02. Moving that request to Sonnet 5.5 means writing the whole history into Sonnet's cache: about $0.25. Moving it to Haiku 5.5 costs about $0.06, because Anthropic prices any Haiku 5.5 request whose prompt exceeds 100,000 tokens at its higher tier ($0.625 per million for a five-minute write).
The bigger cost is often the trip back. If you return to Opus within its cache lifetime, Opus reads its old prefix and writes only what was added while you were away. If the cache has expired, Opus rewrites the whole history: about $0.50 at 100,000 tokens. Claude Code's docs say the tool now asks for confirmation before a /model switch only while the cache is still warm, which is when the switch costs the most.
The Claude Code team's own advice is to switch through subagents instead. In the same post, Shihipar gives the example of a conversation 100,000 tokens into Opus, where asking Haiku an easy question "would actually be more expensive" than letting Opus answer, and recommends having Opus write a "hand-off" message for the other model, which is how Claude Code's Haiku-based Explore agents work. Claude Code's docs explain why this is cheap: a subagent starts its own conversation with its own cold cache, and its call and result are simply appended to the parent's conversation, so the parent's cache survives. A fork is the opposite case: it inherits the parent's prompt, tools and history exactly, on the same model, so it reads the parent's cache.
What it costs over a session
A worked example makes the trade-offs concrete. The assumptions, which are the Tribune's own and not measured traces: a session of 100 requests on Opus 5.5; a 30,000-token starting prefix that grows by 2,000 tokens per request to 228,000; 1,000 output tokens per request; five-minute cache writes throughout; and five detours of two requests each, at requests 20, 40, 60, 80 and 90, sent to a cheaper model. In the handoff case, those ten requests go to a Haiku 5.5 subagent that gets a fresh 10,000-token prompt each time, while the main conversation keeps growing at the same rate. Prices are Anthropic's list prices.
| Strategy | Tokens re-prefilled on switches | Cost per 100 requests |
|---|---|---|
| Opus 5.5, no caching | No cache to lose | $53.60 |
| Opus 5.5 only, cached | 0 | $5.67 |
| Naive switch to Haiku 5.5, Opus cache still warm on return | 0.72M | $5.66 |
| Naive switch to Haiku 5.5, Opus cache expired on return | 1.46M | $9.07 |
| Naive switch to Sonnet 5.5, Opus cache expired on return | 1.46M | $10.59 |
| Haiku 5.5 subagent with a 10,000-token handoff | 0 | $5.20 |
Three things stand out. Caching itself is the large saving, about 89 percent. A naive switch to Haiku 5.5 is roughly free when you come back quickly, because Haiku's cheap output offsets its cold start; it becomes a 60 percent penalty when the Opus cache has expired by the time you return. And the summary handoff is cheapest, because the subagent never reads the 100,000-plus-token history at all. The table leaves out answer quality: a Haiku answer to a question asked of Opus is not the same answer.
Can the limit be removed? Cross-model K/V cache transfer
Researchers have tried to let one model reuse another's K/V cache, and the results show both what is possible and how narrow it is today.
DroidSpeak, a paper first posted in November 2024 and revised in July 2025, reuses K/V caches between models that share a foundation model, such as Llama 3.1 70B and its instruct variant, or Mistral 7B and a fine-tune of it. Reusing another model's cache wholesale fails: the paper reports that on one question-answering benchmark most pairs lose more than half their accuracy points. DroidSpeak instead recomputes the layers that matter most, about 11 percent of them on average, chosen per pair by offline profiling to stay within 5 percent of the receiving model's own quality. That cuts prefill time by 1.7 to 3.1 times and improves time to first token 2.7 times on a coding-agent workflow. The paper says it does not support models built on different foundation models.
Cache-to-Cache (C2C), presented at ICLR 2026, goes across model families with a trained projector that maps one model's cache into another's, tested on open models from 0.6 billion to 14 billion parameters. It solves a different problem: the receiving model still computes its own cache, and the sender's projected cache is fused into it to pass meaning. Its 2.5 times latency gain is measured against one model writing text for the other, not against a cache hit. Its code is released under Apache 2.0 with trained projectors for small Qwen and Llama pairs, and any new pair needs its own projector.
None of this reaches the hosted frontier models coding agents mostly use. A provider would have to run both models and expose the transfer, and none documents that. Parsec, a small language model lab, makes the most direct claim in this direction: its router comparison page says a "universal K/V cache" avoids cache breakage when its routing switches models mid-conversation, and that a switch costs 15 to 19 percent of a full re-read. The page gives no model pairs, workload or method behind that figure, and the service it describes runs on Parsec's own post-trained models rather than on Anthropic's or OpenAI's, with no published price.
What has not been measured is the comparison this question needs: hit rate, time to first token and cost per session for staying on one model, naive switching, summary handoff and K/V transfer, all on the same set of real coding-agent traces. No such benchmark has been published with its method and data, for Claude Code, OpenCode, Aider, Cline or any other agent.
Keeping a single-model cache warm
Most of the saving comes from not breaking the cache you have. The provider docs agree on the basics:
- Choose the model, effort level and fast mode at the start of a session and keep them.
- Keep the prefix stable: fixed tool definitions and system prompt first, anything that varies (timestamps, file paths, per-user details) last.
- Delegate cheaper work to a subagent with a short handoff rather than switching the main conversation's model; use a fork when you want the same model to reuse the parent's cache.
- Run
/compactat natural breaks between tasks, since it rebuilds the conversation cache and you choose when that cost lands; to abandon a path, prefer/rewind, which returns to a prefix already cached. - Watch
cache_read_input_tokensagainstcache_creation_input_tokenson Anthropic (cached_tokensandcache_write_tokenson OpenAI,cacheReadInputTokensandcacheWriteInputTokenson Bedrock). If creation stays high turn after turn, something early in the prompt keeps changing. In Claude Code,/usageshows the session's hit ratio and, on recent versions, the likely cause of the last miss.
Two provider details catch teams out. Anthropic silently skips caching prompts below a model's minimum, 512 tokens on the 5.5 models and 4,096 on Haiku 4.5. And Bedrock's docs say a cache entry lives on the server that processed it, so cross-region inference "may lead to increased cache writes."
Bottom line
If you run a coding agent on one model, prompt caching is not optional: it cuts input cost by roughly an order of magnitude, and the job is to protect the hit rate. If you want a cheaper model for side tasks, send them to a subagent with a short handoff and keep the main conversation on one model. If you must switch the main conversation, do it right after a recent request, while the original model's cache is warm, and avoid opusplan on long contexts. If you hoped to share one cache across Opus and Haiku, you cannot on any hosted API today; cross-model K/V transfer works only in research systems on open models, mostly within one model family.
Sources
- Claude Code docs, How Claude Code uses prompt caching: https://code.claude.com/docs/en/prompt-caching
- Anthropic, Prompt caching (API docs): https://platform.claude.com/docs/en/build-with-claude/prompt-caching
- Anthropic, Pricing: https://platform.claude.com/docs/en/about-claude/pricing
- Anthropic, Models overview: https://platform.claude.com/docs/en/about-claude/models/overview
- Anthropic blog, Lessons from building Claude Code: Prompt caching is everything (April 30, 2026): https://claude.dev/blog/lessons-from-building-claude-code-prompt-caching-is-everything/
- OpenAI, Prompt caching guide: https://developers.openai.com/api/docs/guides/prompt-caching
- Amazon Bedrock, Prompt caching: https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html
- DroidSpeak: KV Cache Sharing for Cross-LLM Communication and Multi-LLM Serving: https://arxiv.org/abs/2411.02820
- DroidSpeak, full text (v4): https://arxiv.org/html/2411.02820v4
- Cache-to-Cache: Direct Semantic Communication Between Large Language Models: https://arxiv.org/abs/2510.03215
- Cache-to-Cache, full text (v2): https://arxiv.org/html/2510.03215v2
- C2C code repository: https://github.com/thu-nics/C2C
- Parsec vs routers: https://parseclab.ai/compare/routers/