A product team puts the current time in the first line of an insurer support agent's system prompt, so the agent can say "good morning". The answers do not change. On the sizes this chapter uses, the input bill for every call rises more than eightfold, and the first word of every reply arrives later. The line is harmless as text. Its position is the problem.

Thesis: A prompt cache keeps the work the model did reading the start of a call, so a later call that begins with exactly the same tokens skips it; reuse stops at the first token that differs. Everything before the first change is cheap and fast, everything from it on is paid for and computed again, so a call should be ordered by how often each part changes, and any edit near the top is a deploy.


How the Model Reads the Window ended with the KV cache, the keys and values the model computes for every position of a call. This chapter keeps them for the next call.

From the KV Cache to the Prompt Cache

The KV cache lives for one call. A prompt cache is the provider keeping that computed state for the start of a call, the prefix, after the call ends, so that a later call starting with the same tokens can skip their prefill. An agent loop is built for it: each call re-sends the last one plus a tail, as Anatomy of a Turn showed.

Why only an exact prefix? Because of attention. The key and value at each position were computed from that token and every token before it. Change one token, and every position after it would have had different inputs, so its stored state is wrong. The open-source serving engine vLLM documents this directly: its automatic prefix caching identifies each block of stored state by the tokens in the block and all the tokens before it. Hosted providers do not publish their internals, but their rules behave the same way: reuse holds for an identical prefix and stops at the first difference.

The Rule, Stated Once

Vendors differ in how caching is switched on, how long an entry lives, the minimum prefix it applies to and the discount, and those terms change often; read your provider's current page (Anthropic, OpenAI) rather than any summary. The shape is common. Reused tokens are billed at a cache-read rate, which Anthropic sets at a tenth of the input price or less (a twentieth on its current Opus and Sonnet models), while writing a new entry can cost more than plain input. And the order matters: Anthropic reads a call as tools, then the system prompt, then the messages, and a change at any level invalidates that level and everything after it. Deleting counts as a change, including the provider's own clearing of old tool results.

Change One Block

The lab below lays out one call of the insurer's agent in the order the provider reads it. Choose what changed since the last call, and where a line holding the current time sits. Every block before the first change is reused from the cache; the first changed block and everything after it are read in full, which is both the price and the prefill work before the reply can start. The sizes are illustrative, and the cost is in full-price tokens: a reused token counts a tenth, the cautious end of the range, so on a model with a cheaper cache read the gaps are wider still. With JavaScript off, the table shows the same five cases.

What changed since the last call Time line Reused from the cache Read in full Input cost, in full-price tokens
Nothing: a new message appended Just above the new message 29,000 220 3,120
Nothing: a new message appended First line of the system prompt 3,000 26,220 26,520
A tool definition edited Just above the new message 0 29,220 29,220
The system prompt edited Just above the new message 3,000 26,220 26,520
An early message removed Just above the new message 23,000 6,220 8,520

Illustrative sizes: tool definitions 3,000 tokens, system prompt 20,000, history 6,000, the time line 20, the new message 200. A cache read counts a tenth of a full-price token, the cautious end of the range; the premium for writing a new entry is left out. Assumes a cache entry ends after each block and is still live, and that each call's time line stays in the history as it was sent. The removed-message row keeps the history at 6,000, so its full read and its cost are high by the removed message's size.

The first two rows are the opening of this chapter. With the time line just above the new message, 29,000 of 29,220 tokens are reused and the call costs the equivalent of 3,120 full-price tokens. Move the same 20 tokens to the first line of the system prompt and only the tools are reused: 26,520, about eight and a half times as much, for the same words in the call.

Order the Call by How Often It Changes

Laid out by how often each part changes, one call of an agent looks like this. Everything up to the end of the last call can be served from the cache, as long as nothing in it changed; the tail is new and is read in full.

flowchart TB
  subgraph Same[Unchanged since the last call: reusable]
    direction LR
    T[Tool definitions] --> S[System prompt] --> F[Stable reference<br/>material] --> H[History up to<br/>the last call]
  end
  subgraph New[New on this call: read in full]
    direction LR
    R[Retrieved passages<br/>for this ask] --> U[The new message<br/>or tool result]
  end
  Same --> New
  style Same fill:#e8f5e9
  style New fill:#fff3e0

Figure: What a cache can reuse. Tool definitions, the system prompt, stable reference material and the history up to the last call are unchanged and reusable; retrieved passages and the new message are read in full on every call.

The insurer's team has three versions of the same mistake to avoid. A greeting with the customer's name at the top of the system prompt ("You are helping {name}, a Gold member since {year}") is stable within one conversation but different for every customer, so the 20,000-token policy can no longer be shared across conversations; below the policy, it costs nothing extra. The current time at the top changes on every call, so nothing after it is reused even inside one conversation. An edited tool description, pushed mid-day, invalidates every live cache entry at once, because tools come first.

The same layout is why the 238-tool call was priced at the cache-read rate: its large tool array sat unchanged at the very top of every call in the session. That made it cheap to re-send, not free, and it still filled the window on every call.

Prefill Is Time, Not Only Money

Tokens read in full are prefill work, and prefill is the pause before the first word of the reply. A call that reuses 29,000 tokens and reads 220 starts answering sooner than one that reads 26,220, on any provider. Providers report how many tokens a call read from the cache in the usage data of each response, so the effect is visible per call: a sudden drop in cached tokens is usually someone editing the top of the prompt.

When the Cache Does Not Matter

Short or one-off calls. A 500-token classification call is under every minimum cacheable prefix Anthropic and OpenAI list (512 tokens and up, by model) and runs once.

When it makes "send everything" reasonable. At a tenth of the input price or less, a large stable block of reference material is cheap after the first call and spares a retrieval step that can miss. That is a price argument only: the cached tokens are still in the window, and the position and length effects from How the Model Reads the Window apply to them as much as to anything else.


What to Do Next

  • Order the call by how often it changes. Tools, then the system prompt, then stable reference material, then history. Names, dates, times and request IDs go below the shared part, never above it. Append a time line with the new message and never rewrite an earlier one: rewriting is an edit.
  • Log cached tokens per call. Alert on a sudden drop, and diff two consecutive calls as sent to find the first difference.
  • Treat tool and system-prompt edits as deploys. Each one resets the cache for every conversation that shares it.
  • Remember that deleting is an edit. Trimming early history or clearing old tool results saves window space and costs a re-read of everything after the cut; do it in batches, not one message at a time.

Next in the series: From Logits to Response, on how each token of the reply is drawn. Related reading: Your Tool Schemas Are the Bloat for the full measurement behind the 238-tool call, and What Compaction Actually Destroys for what happens when the history is shortened.