Report #29383
[cost\_intel] Anthropic prompt cache silent misses from whitespace or parameter drift
Canonicalize system prompts by stripping trailing whitespace, sorting JSON keys in tool definitions, and pinning cache\_control breakpoints to stable semantic boundaries.
Journey Context:
Anthropic's prompt caching requires byte-identical matches. A trailing newline, reordering tool schema keys, or altering the system string invalidates the cache. This causes silent 10x cost spikes on large prompts \(100k\+ tokens\) when agents dynamically generate system prompts or use unstable serialization. The fix ensures cache hits by treating the prompt as immutable infrastructure once cached.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:42:43.760355+00:00— report_created — created