The Attention Budget
Why a bigger context window isn't a free lunch - the model's focus is finite, and more text can make it dumber, not smarter
The Surprising Core Truth
Here's the fact that makes context engineering necessary: giving a model more text can make its answers worse. It feels backwards - more information should mean more to work with. But the model's ability to focus is limited, and every extra token spends a little of that focus.
Context Rot: More Tokens, Worse Recall
Researchers tested models by hiding a single fact (a "needle") inside larger and larger piles of text (the "haystack") and asking the model to find it. The result is consistent across every model: as the pile grows, the model gets worse at finding the needle. This is called context rot.
Recall accuracy as context fills up (the shape, not exact numbers): small context โโโโโโโโโโโโโโโโโโโโ very reliable medium context โโโโโโโโโโโโโโโโโโโโ slipping huge context โโโโโโโโโโโโโโโโโโโโโ unreliable It's a gradual slope, not a cliff - the model stays capable, but it gets less precise the more you cram in.
Lost in the Middle
There's a second, sneakier effect. Models don't pay equal attention to all parts of the context. They reliably notice what's at the beginning and the end, and they tend to miss things buried in the middle. This famous finding is literally called "lost in the middle."
Where the model actually pays attention: START โโโโโโโโโโโ strong โ put your key facts here MIDDLE โโโโโโโโโโโโ weak โ stuff gets lost here END โโโโโโโโโโโ strong โ ...or here So the ORDER you assemble context in matters as much as what's in it. Bury the crucial fact in the middle of a 30,000-token wall and the model may never "see" it.
The Real Cost of "Just Dump Everything"
The instinct when an agent fails is to give it more context, just to be safe. It feels responsible. It usually backfires three ways:
Context rot and lost-in-the-middle kick in. Teams routinely find an agent does worse with a 100,000-token codebase dump than with a 5,000-token targeted slice.
You pay per token. A bloated context is a bloated bill, on every single turn of a long-running loop.
More tokens means more compute per step, so latency climbs. A chatty agent that re-reads a huge context every turn crawls.
"But Context Windows Keep Getting Bigger!"
True - models now hold hundreds of thousands or even millions of tokens. Doesn't this problem just go away? No. A bigger desk doesn't fix bad desk management:
- Context rot and lost-in-the-middle still apply - even at 2 million tokens, you still want the model to see just what's useful.
- Cost and latency grow with size, so a giant context is expensive and slow even when it works.
- The discipline is permanent: as long as windows are finite (they always are), someone must decide what enters. That someone is the context engineer.
The Mindset This Sets Up
Everything in the next five lessons flows from this one idea. Each pillar - instructions, retrieval, memory, tools - is really an answer to the question: how do I spend my limited attention budget wisely?
Hands-On: Feel the Rot
The model's focus is finite; every token spends some of it, so more context can mean worse answers
As the context window fills, the model's ability to recall any specific fact gradually drops
Models attend to the start and end of context far better than the middle - so order matters
The goal: the fewest tokens that maximize the chance of the right outcome
Too much context lowers quality, raises cost, and adds latency - all at once
Rot, lost-in-the-middle, cost, and latency persist even at millions of tokens