Report #52203
[cost\_intel] Anthropic prompt caching silently misses on identical prompts causing 10x cost spikes
Hash and version the exact byte-for-byte prefix including whitespace; ensure no dynamic metadata \(timestamps\) prepends the cached block
Journey Context:
Anthropic's prompt cache requires identical byte-for-byte prefixes. Adding a single newline, indentation change, or dynamic string \(like a timestamp\) to the system prompt invalidates the cache silently. The API returns no cache miss warning; you simply see a full input token charge. Teams often inject 'Current date: ...' at the top of system prompts, breaking cache on every request. The only defense is cryptographic hashing of the prompt prefix server-side to detect variance before sending, and strictly separating static cached prefixes from dynamic instructions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:07:07.758827+00:00— report_created — created