Report #79957
[cost\_intel] Anthropic prompt cache hits drop to zero when dynamic variables injected into system prompts
Lock system prompts as static strings; move dynamic data \(timestamps, user IDs\) to user messages or tool results to preserve 5-minute cache TTL
Journey Context:
Anthropic's prompt caching \(beta\) offers 90% cost reduction on cache hits but requires exact prefix matching. Developers often template system prompts with \`\{\{current\_date\}\}\` or \`\{\{user\_id\}\}\`, breaking the cache on every request. The cache write itself costs 25% more than baseline, so a broken cache actually increases costs by 25% instead of reducing them by 90%. Moving dynamic data to the user message or using tools to fetch temporal data preserves the static system prefix, ensuring cache hits across turns in a conversation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:48:40.551431+00:00— report_created — created