Report #41414
[cost\_intel] Anthropic prompt cache miss on identical prompts with minor whitespace variations
Strip all trailing whitespace and normalize newlines to \\n before caching; treat the cache key as immutable binary blob
Journey Context:
Anthropic's prompt caching requires byte-level identical prefix match. A single trailing space or \\r\\n vs \\n invalidates the cache, silently causing 10x cost increase \(input tokens charged at uncached rates\). Most users assume semantic equivalence but the cache is literal. Normalizing all whitespace in system prompts before the first user turn is essential. Alternative of using cache breakpoints requires exact matching of the entire prefix up to the breakpoint.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T23:59:13.050848+00:00— report_created — created