Prompt Caching

Where the support graph asks for prompt caching, why nothing is cached on Haiku 4.5 today, and what it would take to change that.


Nothing is cached today. The answering call marks its system prompt with a cache breakpoint, but Claude Haiku 4.5 never caches a prefix shorter than 4,096 tokens, and answer.md is about 750. The request succeeds with no error; cache_creation_input_tokens stays 0.


How Anthropic’s cache control works

Adding cache_control: {"type": "ephemeral"} to a content block asks Anthropic to store the computed prefix up to that block for 5 minutes. On the next request, if the prompt up to that marker is byte-identical, those tokens are read from cache instead of recomputed.

  • Prefix match. The prefix runs tools → system → messages. One changed token before the marker invalidates it.
  • Write, then read. A write bills at 1.25× the input rate, a read at 0.1×. See the rates in config/pricing/claude.yaml.
  • A minimum length, per model. A shorter prefix is silently not cached.
ModelMinimum cacheable prefix
Claude Opus 5512 tokens
Claude Sonnet 4.61,024 tokens
Claude Haiku 4.54,096 tokens

The minimum is not monotonic across generations: the cheapest model has one of the highest.


The one breakpoint

# templates/documents.py · answer_request_kwargs()
"system": [
    {"type": "text", "text": _prompt(cfg, "answer"), "cache_control": {"type": "ephemeral"}}
],
"messages": history + [{"role": "user", "content": search_results + [question]}],
  • It covers the system prompt only. The request carries no tools, so the cached prefix would be answer.md and nothing else.
  • The grade, rewrite and draft calls set no breakpoint. Their prompts are 250 to 950 words, all under Haiku’s minimum.
  • History has no breakpoint. Each turn resends the conversation at the full input rate.

When it would pay

ChangeEffect
Switch agent.model to Sonnet 4.6 or Opus 5answer.md clears the 1,024- or 512-token minimum, and the existing breakpoint starts writing
Grow a Haiku system prompt past 4,096 tokensThe same, on the current model
Add a breakpoint on the last history messageLong conversations read their history from cache; the passages and question stay uncached

For scale: a 5,000-token system prompt over 10 turns on Haiku 4.5 costs $0.050 uncached and $0.011 cached (one write at 1.25×, nine reads at 0.1×). At today’s ~750-token prompt and short support conversations, the saving would be a fraction of a cent per turn.


Verifying it

The done event and every model step report the two cache counters:

{
  "input_tokens": 3120,
  "output_tokens": 412,
  "cache_creation_input_tokens": 0,
  "cache_read_input_tokens": 0,
  "cost_usd": 0.00518
}
  • Both 0 on every turn: the prefix is under the model’s minimum, or something in it changes per request.
  • A write on turn 1, reads after: caching works. The chat UI shows a “cached” badge whenever cache_read_input_tokens is above zero.

What the retired loop did

The loop set two breakpoints per call: the system prompt, behind a tool list sorted by name so its serialization never changed, and the last content block of the latest message, re-applied to a copy on every call so markers never accumulated past the four-breakpoint limit. Both went with the loop in D11. See Retiring the Loop.