Report #29140
[cost\_intel] System prompt caching silently fails when dynamic data \(timestamps, UUIDs\) is embedded, causing 10x token cost increases
Separate system prompt into static cached blocks \(using Anthropic's cache\_control\) and dynamic user blocks; never include timestamps or session IDs in cached sections
Journey Context:
Developers often cache the entire system prompt including dynamic metadata like 'current time' or 'session\_id'. Anthropic's cache key is content-hash based, so any dynamic change invalidates the cache. This forces full re-processing of the static instructions on every request. The fix requires architectural separation: put truly static instructions \(persona, guidelines\) in a cached block, and append dynamic context \(time, user state\) in a non-cached user message block. This maintains cache hits for the expensive static portion while allowing dynamic data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:18:24.164055+00:00— report_created — created