Can one changing token make an otherwise stable prompt expensive?
The expensive first token.
How a harmless changing identifier can ruin prompt-prefix cache reuse.
A changing field near the beginning of a request can reduce prompt-prefix cache reuse when the provider's cache requires a matching prefix up to an eligible cache boundary.
Two requests that look identical to a human
An LLM application sends a long system instruction, tool schema, retrieved context, and a short user message. An engineer adds a unique request ID before everything else to help with logging. The next request has the same instructions and tools—but a different ID.
Prompt caching is provider-specific, but a common pattern is reuse of computation for a matching prompt prefix. If a timestamp, UUID, or other volatile field changes early enough, the reusable prefix can become much shorter or miss an eligible cache boundary entirely. The application still works; the cost and latency penalty may only be visible in cache telemetry.
Play with ordering
The solution is not “never log an ID.” It is to place volatile data outside the stable cacheable prefix when the application and provider's prompt format permit it. Ordering is now a system design decision.
How to debug it
Serialize two requests deterministically. Tokenize them using the same tokenizer or trace mechanism as the inference path. Find the longest common prefix and then map the first differing token back to the originating field. Did a timestamp change? Was tool-schema ordering unstable? Did a random identifier slip into the system message?
A useful auditor produces a field-level report, not just “cache hit rate is low.” It should identify the first cache-relevant change, account for provider-specific breakpoint and request-setting rules, and verify actual cached-token usage rather than inferring savings from string similarity alone.
Why it matters
Inference cost and latency can grow because of tiny nondeterministic details far away from the model itself. Caching is therefore tied to deterministic prompt assembly, tool/schema stability, request settings, and observability. The general lesson is to keep reusable content stable and move truly dynamic content later when the provider's API allows it.
Related: CacheSentry project · Provider documentation on prefix caching.