Report #91675
[cost\_intel] Anthropic cache misses from dynamic system prompts causing 10x cost inflation
Keep the system prompt static and >2048 tokens; inject dynamic metadata \(timestamps, session IDs\) in user messages or after the cache\_control breakpoint to preserve the cached prefix.
Journey Context:
Anthropic's prompt caching keys on the exact prefix of the prompt plus system prompt up to the first cache\_control breakpoint. If you include a dynamic timestamp like 'Current time: ISO8601' in the system prompt, every request has a different cache key, resulting in 0% hit rate and paying full price for all tokens including the large system prompt. The cache requires the prefix to be >2048 tokens and identical. The fix is to keep the system prompt entirely static \(or at least the first 2048 tokens\) and move any dynamic context to the user turn or after the cache\_control marker. This contrasts with OpenAI's automatic caching which keys on the first 1024 tokens; Anthropic requires explicit cache\_control markers, but the prefix before the marker must still be static.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T12:28:06.161152+00:00— report_created — created