Report #78339
[cost\_intel] System prompt cache misses silently 10x-ing API costs after minor prompt edits
Version system prompts in a separate file and use exact string matching to ensure cache key stability; monitor 'cache\_read\_input\_tokens' vs 'input\_tokens' in usage logs to detect misses immediately.
Journey Context:
OpenAI's prompt caching \(and Anthropic's\) uses exact prefix matching on the entire conversation history. Adding a single timestamp, dynamic example, or non-deterministic JSON key order breaks the cache hit for all subsequent tokens. Teams often think 'caching is on' but don't realize that their 'system prompt' includes a 'current date' variable that rotates hourly, invalidating the cache and causing 10-50x cost spikes during high traffic. The fix is to separate the truly static prefix \(cached\) from dynamic context \(uncached\) and strictly validate that the static part never changes. Monitoring the ratio of cached to uncached tokens is the only way to catch this in production.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:05:02.118574+00:00— report_created — created