Part 2 · The Four Rights

Token Engineering · ~7 min

Right Cache — Caching Discipline

A prompt cache is the cheapest token there is — but it only pays out if your prefix is stable and your tokenizer never moves underneath it.

Why this, for you: you turned on prompt caching, watched the bill drop, and moved on. Then a model upgrade — or a single reordered system block — quietly dropped your hit rate to near zero and nobody noticed until the invoice. Cache savings are structural: they live in how you order context, not in a flag you flip once.

The first two Rights cut tokens you send. This one makes the tokens you re-send nearly free. A prompt cache discounts any leading run of tokens identical to a previous call — so the discount is a property of ordering, and it is silently fragile to anything that changes how text becomes tokens.

1 Stable-first, or no hit at all

Caching matches on a prefix. The model can reuse compute only up to the first token that differs from the previous request. One byte of drift near the front voids everything after it. So the discipline is brutally simple: put what never changes first, what changes every call last.

PositionPut hereWhy
Front (cached)System prompt, tool schemas, fixed instructionsIdentical across calls → long shared prefix
MiddleStable reference docs, retrieved corpus that rarely changesStill in the shared run if ordered consistently
Tail (uncached)The user turn, timestamps, per-call IDsChanges every call — keep it out of the prefix
A volatile value — a timestamp, a session ID, a reordered tool list — placed before your stable context moves the first-difference point to the very top. Everything behind it becomes uncacheable. Order stable-first or the cache simply never fires.

2 A tokenizer swap silently voids the cache

Caching matches on tokens, not characters. So the matching prefix only survives while the same text maps to the same token sequence. A model upgrade that ships a new tokenizer remaps that text — the cached prefix no longer exists in the new vocabulary, and every previously cached token is gone. The pricing page shows no change, which is exactly why this bites.

Anthropic documents the Claude Opus 4.7 tokenizer as producing roughly 1.0–1.35x as many tokens (up to ~35% more, varying by content) for the same text versus prior models — at unchanged $5 / $25 per MTok pricing and an unchanged 1M-token window. Simon Willison measured the real spread against the count_tokens endpoint, and it is workload-shaped:

Input4.6 → 4.7 tokensMultiplier
System prompt (raw text)5,039 → 7,3351.46x
30-page text-heavy PDF56,482 → 60,9341.08x
682×318 image310 → 314~1.00x
3456×2234 high-res PNG1,578 → 4,7443.01x

The cost looks flat on the pricing page

Flat per-token price × a higher token count is a price increase the pricing page does not show. A migration that re-tokenizes your stable system prefix at 1.46x both inflates spend and invalidates the cache that was hiding that prefix's cost — two hits from one swap.

3 Re-count before you cut over

The headline multiplier is a spread, not your number. Anthropic's migration guide names concrete pre-cutover work — and the cache-fit check is part of it. Re-run representative prompts through both tokenizers, then update the envelopes the new count shifts:

# Forecast from a MEASURED, content-weighted multiplier — not the vendor max measured_multiplier = 0.70*1.46 + 0.25*1.08 + 0.05*1.00 # = 1.34x projected_tokens = baseline_tokens * measured_multiplier # 1M context now holds ~746K "old-tokenizer-equivalent" tokens effective_context = 1_000_000 / measured_multiplier

And remember the multiplier overcounts: a more capable model can finish tasks in fewer retries, and effort / task-budget controls can absorb part of the lift. Tokenizer arithmetic alone overestimates the migration cost — so forecast from your workload, then check the cache actually still hits after cutover.

↪ Your win: a cache that actually pays out

Retrieval practice — recall, don't peek

Question 1A prompt cache discounts a call based on…

Question 2Putting a per-call timestamp before your stable system prompt…

Question 3A model upgrade that ships a new tokenizer does what to a cached prefix?

Question 4Opus 4.7 tokenizes the same text at roughly… (pricing and window unchanged)

Question 5 · spaced recall from an earlier lessonTo cut output tokens on a code edit, you have the model return…

Ask me anything. Want help laying out a context window so the cacheable prefix is as long as possible, or a count_tokens diff to size a migration before you cut over? Next in Part 2: Right Time — Batch & Temporal Routing, where we trade latency for a real discount on work that isn't urgent.
✎ Feedback