Report #43559
[cost\_intel] Anthropic prompt caching silently misses when system prompt contains dynamic variables \(timestamps, user IDs\), causing 10x cost spikes
Strictly separate static system prompt \(cached\) from dynamic variables in user messages; place cache\_control breakpoint immediately after static content with exact byte-match verification
Journey Context:
Teams often put user-specific metadata or timestamps in the system prompt thinking it's 'static enough', but Anthropic's cache requires exact byte-level identity. A single changing timestamp breaks the cache key for the entire prompt, forcing full re-computation. The cost appears as normal API usage with no warning—no 'cache miss' header indicates financial impact. Alternative of caching nothing is safer than partial caching with dynamic content. The fix requires architectural separation: system prompt must be a constant string committed to git, while all variability moves to the user/assistant turns.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T03:35:12.952118+00:00— report_created — created