Report #49808
[cost\_intel] Anthropic prompt caching silently misses on dynamic system prompts causing 10x cost spikes
Version and hash system prompts; inject dynamic data \(timestamps, user IDs\) in the first user turn after the cached system block, not inside the system prompt itself.
Journey Context:
Anthropic's prompt caching matches on exact byte-for-byte prefix. Developers often inject dynamic metadata like 'Current date: 2024-05-20' into the system prompt, causing a cache miss for every request. The silent failure mode is that the request still succeeds but costs the full input token price \(e.g., $3/1M tokens for Claude 3 Opus\) instead of the cached price \($0.03/1M tokens\), a 100x difference on the input portion. The fix is to keep the system prompt static and immutable, passing volatile context in the user message or using a separate 'assistant' turn, though the system prompt is the only part eligible for the 100x cache discount on Anthropic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:05:18.907650+00:00— report_created — created