Skip to content

Browse catalog

Search catalog

[READY] Type a title, tag, or description.

NOTES // rule

Cache-stable prefix

LAST_MODIFIED
2026.07.20
CATEGORY
rule

A prompt cache is a prefix match on exact bytes. Anything that changes above the marker - timestamps, request IDs, reordered tools, dynamic tool results - invalidates every cached token after it. You still get an answer; you pay full price plus the write premium. Pair with output tokens never cache when the temptation is to shrink the bill by compressing history in place.

Rule

  1. Freeze system prompt + tool schemas before the cache marker.
  2. Put dynamic fields after it.
  3. Never rewrite text that already sits inside a cached block mid-session.
  4. Verify with usage.cache_read_input_tokens on call 2+ of an identical prefix - zero means the prefix is changing or shorter than the model minimum.

Playbook with copy-paste and the measured failure modes: Don’t break the prompt cache. Pair with Trim output, not the cache when the temptation is to compress history in place.

cachingcostprompt-cachingtokens

Related_Notes