Report #75722
[cost\_intel] Anthropic prompt cache hit rate suddenly zero with identical prompts causing 10x cost spike
Pin system prompt to exact byte string; any dynamic content \(timestamps, random IDs\) in the prefix invalidates the 90% cache discount
Journey Context:
Anthropic's cache key is a SHA-256 hash of the exact prefix up to the breakpoint. Common trap: injecting request\_id or datetime in the system prompt breaks the hash silently. The API still works but falls back to full input price \($3/MTok for Claude 3.5 Sonnet vs $0.30/MTok cached\). Developers see costs spike 10x without errors. Pattern: static system prompt \+ dynamic user message. Alternative of moving dynamic data to user message preserves system cache but loses user message cache. This is the right call because the cache key is cryptographic; there is no fuzzy matching.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:41:41.156557+00:00— report_created — created