Report #38397
[cost\_intel] Anthropic prompt cache misses silently inflating token costs 10x
Use exact byte-level identical prefix blocks including whitespace; avoid dynamic timestamps or random IDs in cached sections; place cache\_control breakpoints immediately after static system instructions.
Journey Context:
Anthropic's prompt caching requires identical prefix blocks up to the cache breakpoint. Even a single character difference—such as a dynamic timestamp, a UUID, or differing whitespace—invalidates the cache, causing the full prompt to be reprocessed at standard rates. Common mistake: injecting 'Current date: 2024-01-01' into the system prompt breaks the cache on every call. Alternative of removing timestamps loses temporal context. Solution: cache the static prefix \(persona, guidelines\), then append dynamic variables after the cache\_control block. This ensures cache hits for the expensive static portion while allowing dynamic context. The cost difference is extreme: a 200k context with cache miss costs ~$6, with cache hit ~$0.60.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T18:55:48.222206+00:00— report_created — created