Why a bigger window doesn't fix it
Four limits that don't go away with capacity — cost, quadratic prefill, measured attention degradation, and a flat token sequence having no structure — plus the arithmetic of the alternative.
As of early 2026 frontier models advertise context windows from ~128K tokens on older deployments to ~2M on the longest-context offerings, and the marketing implication is that retrieval and memory are solved by capacity. In practice four limits remain, and three of them get worse as the window fills.
1. Cost scales with every token, every turn
Inference cost scales linearly with input tokens. A 1M-token context, at typical 2026 frontier API pricing, is multiple dollars per call — and an agent makes dozens of calls per session. The bill is not a function of how much the agent said; it is a function of how much you re-sent.
This is the limit that makes the long-context pitch self-defeating for agents specifically. A chatbot answering one question can afford a large prefill once. An agent that loops — read, act, observe, read again — pays it on every iteration, and the thing it re-reads is mostly the same text it re-read last time.
Worth noticing where the cost lands organisationally, too. It is incurred per turn by the busiest users and shows up as an aggregate line on a bill, so the team that can diagnose it (engineering) and the team that sees it (finance) are looking at different numbers. "Our token spend grew 4× this quarter" and "our power users have longer histories" are the same sentence, and they are rarely said in the same meeting.
Prefix caching is the mitigation, and it has a sharp edge. Caches are prefix-based: a cached prefix is only reusable while it stays byte-identical. Appending the new turn is cheap. Re-sorting history, re-summarising, or injecting the newly relevant fact at the top mutates the prefix and invalidates the cache for everything after it.
So the retrieval strategy and the caching strategy are the same decision. A memory layer that reshuffles what it injects on every turn can cost more than no memory layer at all — which is an argument for a stable, bounded, append-shaped context, not merely a small one.
2. Latency scales worse than cost
Time to first token is dominated by prefill, and attention is O(n²) in
sequence length. Efficient attention variants and KV caching reduce the
constant; they do not change the shape. Multi-megabyte contexts add seconds
before the first token appears.
For a batch job that is an annoyance. For an agent interacting with a person in real time it is the difference between usable and not — and it compounds with the loop: every iteration pays the prefill again.
It also interacts badly with the only mitigation available. Prefix caching removes the repeated part of the prefill, so the cached-prefix case is fast — but the first call of a session, and every call after a prefix mutation, pays in full. A system that invalidates its cache on most turns therefore has a latency profile closer to the uncached column than the cached one, while the cost model everyone quotes assumes the opposite.
3. Attention degrades at length, and it is measured
This is the one that surprises people, because it is not a capacity limit — it's a quality one that bites well before the window fills.
Multiple studies show long-context models perform worse at retrieving information from the middle of long inputs: the "lost in the middle" effect (Liu et al., 2023). The model is biased toward content near the start and the end. Newer models reduce the effect but do not eliminate it.
The practical consequence:
Effective capacity is a policy decision you make, not a number the vendor gives you.
Treat the advertised limit as your budget and quality falls silently as your most engaged users accumulate the most history. The agent gets worse for exactly the people who use it most, and nothing in your metrics says why.
There is no threshold to alarm on, either. Degradation is gradual and content-dependent — the same prompt length behaves differently depending on where the needed fact sits — so there is no window occupancy percentage at which you can say "past here, stop". The budget has to come from your own evaluation, measured on your own traffic.
Four shapes the degradation takes
Practitioners report these under different names; they are worth separating because only one is a retrieval problem:
| Failure mode | What happens |
|---|---|
| Poisoning | A hallucination enters the context and is referenced again on later turns, hardening into fact |
| Distraction | Context grows so large the model leans on history instead of reasoning about the question |
| Confusion | Irrelevant content — tool definitions especially — crowds the signal |
| Clash | Accumulated content contradicts itself, and the model picks one, silently |
Only the first is a retrieval-quality problem. The other three are modelling and governance problems wearing a retrieval costume, which is why "we'll improve the embeddings" never fixes them.
They also fail silently and in the same direction, which is what makes them expensive. None of the four produces an error, a warning, or a metric that moves. The agent returns a confident answer built on poisoned, crowded or self-contradicting context, and the only signal is a user who stops trusting it — months after the window started filling.
Clash is the one that matters most here. Put "Priya manages billing" and "Priya moved to platform in June" in the same prompt and the model will pick one. You will not be told which, or why. There is no mechanism that could tell you — both are just sentences in a block of text.
4. No structure, and this one no window size touches
Suppose the first three limits vanished: infinite context, free, instant, with perfect recall at any position. An agent still could not ask:
- What memories are most causally upstream of this observation? — that is a graph traversal.
- Have I seen anything semantically equivalent to X? — that is similarity search with confidence calibration.
- What's the path from my current state to this goal? — that is search over a state space.
Each of those has a known algorithm with known complexity, and none of them is "attend over tokens". You can prompt a model to approximate a graph traversal over text you pasted in, and it will sometimes work — but you are paying transformer inference to simulate a pointer chase, with no guarantee of completeness and no way to ask which edges it actually followed.
A flat token sequence is the wrong shape for all three. Attention over tokens is not traversal over edges, and no amount of capacity converts one into the other. This is why the long-context argument and the memory argument are not actually about the same axis: capacity is a quantity problem, structure is a type problem.
The arithmetic of the alternative
The inversion is easy to state — keep the window small and carry structured state outside the model — and it is worth checking that the replacement is actually cheaper, because an extra network service is not free either.
A retrieval against a purpose-built memory layer targets:
| Operation | p50 | p99 |
|---|---|---|
recall (CPU embeddings) | ≤ 8 ms | ≤ 20 ms |
recall (GPU embeddings) | ≤ 2 ms | ≤ 5 ms |
recall (cue already embedded) | ≤ 1.5 ms | ≤ 4 ms |
encode (CPU) | ≤ 12 ms | ≤ 25 ms |
Against a budget of 100–300 ms for a turn that "feels responsive", a recall is a rounding error — and it is being compared against seconds of prefill on the context it replaces. The embedding dominates those numbers, which is why a repeated cue drops to 1.5 ms: the expensive part is already cached.
So the trade is roughly: pay ~8 ms and a few thousand tokens of selected context, instead of seconds and hundreds of thousands of tokens of everything. That is the whole argument, and it holds for any memory layer — not just this one.
The second-order effect is larger than the first. Because the retrieved set is small and stable, it can sit in a cached prefix across turns instead of being rebuilt; because it is selected rather than accumulated, it does not grow with session length. A full-window agent's cost curve rises with every turn of history. A retrieval agent's is roughly flat, and flatness is what makes the difference compound over a long-running session rather than showing up once.
A worked turn
Make it concrete. An agent on turn 40 of a support conversation, with 38 turns of history and a 12-turn-old fact that matters:
The middle row is the one people underweight. The full-window version isn't losing because it lacks the fact; it has the fact. It's losing because having the fact and using the fact are different, and the position effect decides which one you get.
What you're actually trading away
The honest version of this page has to include the other column, because the inversion is not free:
The first row is the real cost and deserves to be stated plainly: a retrieval system can fail by omission in a way a full window cannot. The compensation is that the omission is inspectable — you can ask which retriever surfaced what and why something didn't make it — whereas a model quietly under-attending to the middle of a long prompt leaves no trace at all.
When the big window is genuinely right
Not every workload needs this, and treating it as universal would be the same mistake in the other direction. Put everything in context when:
- the task is one-shot — a single question over a single document, with no cross-session state to carry;
- the corpus genuinely fits and is small, so the prefill is paid once and stays cached;
- the content is authored and self-consistent — a contract, a spec — so there is no contradiction for the model to adjudicate silently;
- you are prototyping, and the cost of being wrong is one more iteration.
The honest summary of this page, then: long context and memory are not competing answers to one question. They answer how much can the model see right now and what is still true about this subject — and a system that needs the second cannot buy it with more of the first, at any price.
The argument on this page is about agents that run for hours or weeks and accumulate state about people. It is not an argument that retrieval beats context in general.
A useful reframing: the question isn't how much context can I afford? but how much of this context is still true? For a contract, all of it, forever — so send it. For a six-week relationship with a user who changed their mind twice, some unknown subset — and "send everything and hope" is a strategy that degrades precisely as the relationship gets more valuable.
The inversion
For the workloads where it does apply, the conclusion isn't a smaller window. It's a different division of labour:
Keep the context window small — a few thousand tokens of genuinely relevant memories — and let a database carry unlimited structured state outside the model.
That gives you a bounded, ranked, stable set of things worth sending this turn, chosen by something that knows which facts are current, keeps the prefix stable, and can tell you afterwards why it chose them.
That is a different job from storage, and it is the one the rest of these pages describe.
The database does not assemble your prompt
One boundary is worth stating because it is a common expectation and a deliberate refusal: a memory layer returns records, not a block of context ready to paste in front of a question.
Concatenating prior context into a prompt is the agent's job. A database that did it for you would have to decide the ordering, the formatting, the token budget and the truncation policy — four decisions that belong to whoever owns the model call, and four more ways for a prefix to mutate behind your back and cost you the cache. It also does not run your model: there is no inference inside, so "give me the answer" is not an operation it offers.
What you get instead is a bounded set of records with scores, provenance and timestamps, and a free hand in how they become text. That hand is what lets you keep the prefix stable — append-only ordering, stable formatting — which section 1 argued is worth more than any ranking improvement.
Try it
In the playground, run Promotion — it writes a role, then a later fact that contradicts it. Then switch to Read and ask who leads the team.
Then count the tokens you'd have sent under each approach. The full-window version carries both sentences and leaves the model to choose; the retrieval version carries the current one and the fact that it superseded something.
Open Graph: both claims are there, with the older one's validity closed off
and an edge to the one that replaced it. The clash is recorded rather than
left for the model to adjudicate silently — your code can read which is current
and send only that. See when facts collide for why that
read goes to the statement graph and not to recall.
Was this page helpful?
Why agents forget
Inference is stateless, so an agent's only memory is the text you rebuild into the prompt — and the stack teams assemble to decide what that text should be has six invisible bills.
Why RAG isn't memory
A text chunk has no subject and no validity interval, so two chunks can never disagree — and the four places a vector database's model is the wrong shape for an agent's memory.