Long-context failures are usually diagnosed as reasoning problems. Often they are cache problems. When the KV cache cannot hold the full prompt, the serving stack evicts or truncates, and the model answers with part of its instructions missing. The output is fluent, confident and wrong in a way that looks like the model “forgot.”
What the cache does
During prefill, the model computes key and value tensors for every input token. These tensors are reused during decode so the model does not re-read the prompt for each new token. Cache memory grows with prompt length, batch size and model size. It is the binding constraint in long-context serving.
Three eviction behaviors
| Behavior | What the model sees | Typical symptom |
|---|---|---|
| Truncate head | Loses system instructions | Ignores role and format rules |
| Truncate middle | Loses retrieved evidence | Ungrounded claims, missing citations |
| Sliding window | Loses early turns | Contradicts earlier conversation |
Each is a defensible engineering trade. None is acceptable if it happens silently under a contract that promises long context.
Key takeaway Ask what happens to a prompt that exceeds the cache, not just what the maximum context length is. The answer determines your real usable context.
Why batching makes it worse
Cache memory is shared across the batch. A stack that admits a burst of long requests must either reduce batch size, evict, or reject. Under load, the same prompt that worked in testing may be served with a smaller effective context. Quality therefore degrades exactly when traffic is high — the worst possible time for a silent change.
Testing for it
A practical probe uses a long prompt with three planted facts: one in the system instruction, one in the middle of retrieved text, one in the final paragraph. Ask a question that requires all three. Run it alone, then under concurrent load. If accuracy drops only under load, the stack is evicting.
Vary prompt length around your expected p95 and p99. Plot accuracy against length; a cliff is more informative than an average.
Design responses
- Budget context deliberately. Put critical instructions first and repeat them last; do not rely on a single position.
- Compress retrieval. Fewer, better passages reduce cache pressure and often improve groundedness.
- Separate long-context workloads. Route them to a pool sized for cache rather than sharing with short chat traffic.
- Contract the behavior. Require disclosure of eviction policy and a usable-context guarantee at your load profile.
Disaggregated serving helps here: isolating prefill and decode lets the cache be sized for the decode pool’s working set rather than compromised across phases. See KV cache in disaggregated serving.
The quality accounting angle
Eviction-driven failures are expensive: they generate retries and human review while looking like ordinary model behavior. They also inflate the effective-token denominator. If long-context workloads show a worse effective-token rate than short ones, cache policy is the first suspect, not the prompt.
FAQ
Does a larger advertised context window guarantee quality?
No. Quality depends on whether the window is actually held under your load. Advertised maximum and usable context are different numbers.
Is prompt compression a substitute for cache capacity?
It helps, but it is lossy. Use it as a design choice, not as a workaround for undisclosed eviction.
How do we detect eviction from outside?
Load-dependent accuracy drops on long prompts with facts at multiple positions are the signature. Compare isolated and concurrent runs.