I watched a team spend three weeks migrating their agent to a model with a million-token context window. They were convinced it would fix their retrieval problems. It didn’t. Accuracy went down. Latency tripled. The bill went up by a factor of nine.
That story isn’t unusual, and it’s the fastest way I know to explain why context engineering became the discipline everyone suddenly cares about in 2026. The models got enormous windows. The teams filling them found out the hard way that capacity and usefulness are different things.
This is a practical guide to what context engineering actually involves in 2026, why stuffing more into the window usually makes things worse, and eight techniques that work better. Some of them will feel counterintuitive. One of them — the compaction section — contradicts advice I gave people myself a year ago.
In this guide:
- What Context Engineering Actually Means
- Why a Bigger Window Didn’t Fix Anything
- The Four Ways Context Goes Wrong
- 8 Context Engineering Techniques That Actually Work
- How to Measure Whether Any of This Helped
- Five Context Engineering Mistakes I Keep Seeing
- Where This Is Heading
What Context Engineering Actually Means
The term gets used loosely, so it’s worth pinning down. Prompt engineering was about wording: how you phrase the instruction. Context engineering is about everything else in the window — and in 2026, that’s the larger share of the problem by a wide margin.
The working definition I like: context engineering is the practice of deciding what the model sees on every single call. What stays in the window. What gets dropped or compressed. What lives outside the window entirely, in files or a retrieval index, and gets pulled in only when needed.
That framing matters because it turns a vague quality problem into a set of engineering decisions you can actually test. “The agent forgot what we discussed” isn’t a mysterious model failure. It’s a question about your retention policy. “The agent used a stale API signature” isn’t hallucination in the abstract — it’s a question about whether your context had the current docs in it.
If you’re building on top of retrieval-augmented generation, you’re already doing a version of this. Context engineering is the wider frame around it: retrieval is one input among several, alongside system instructions, tool definitions, conversation history, scratchpad notes, and live data.
Why a Bigger Window Didn’t Fix Context Engineering
Here’s the finding that reframed the whole field: model performance degrades as context grows, and it starts degrading far earlier than the advertised limit.
The phenomenon has picked up the name context rot. Research from Databricks found model correctness starting to fall off somewhere around the 32,000-token mark — nowhere near the million-token ceilings being marketed. You are not getting a million tokens of reliable attention. You’re getting a large buffer, most of which the model attends to unevenly.
Layered on top is the lost in the middle problem, which has been reproduced consistently: information sitting in the middle of a long context gets underweighted compared to material at the beginning or the end, more or less regardless of how relevant it is. Put the critical constraint in paragraph forty of a sixty-paragraph context and there’s a real chance the model behaves as though you never said it.
There’s a cost dimension too, and it’s less discussed than it should be. Every token in your window is a token you pay for on every turn. An agent that carries 200,000 tokens of accumulated history into each call isn’t just slower and less accurate — it’s burning budget on material the model is mostly ignoring. That’s the same dynamic driving the credit-burn complaints across AI coding assistants, where agent mode can consume orders of magnitude more tokens than a simple completion.
The conclusion the field arrived at is uncomfortable for anyone hoping hardware would solve this: the answer isn’t a bigger window. It’s better curation. You want the minimum set of high-signal tokens that lets the model do the job.
The Four Ways Context Goes Wrong
It helps to have names for the four failure modes context engineering exists to prevent, because the fix is different for each one.
Poisoning. A hallucination or a wrong fact enters the context early, then gets referenced repeatedly on subsequent turns as though it were established truth. The model isn’t re-deriving it — it’s reading its own earlier mistake. This is especially common in long agent runs, and especially damaging, because the error compounds silently.
Distraction. The context grows large enough that the model over-anchors on the conversation history and under-uses what it actually knows. You see this when an agent keeps circling back to an approach that failed twenty turns ago instead of trying something new.
Confusion. Irrelevant material in the window pulls responses off course. The clearest case is tool definitions: models measurably perform worse when handed a large set of available tools than a small, relevant one. More options is not more capability.
Clash. Two parts of the context directly contradict each other — an old requirement and a revised one, or a stale file version alongside the current one. The model has no reliable way to know which one wins, so it picks, and sometimes it picks wrong.
Once you’re looking for these, most “the AI is being dumb” complaints resolve into one of the four.
8 Context Engineering Techniques That Actually Work
These are ordered roughly by how much return you get for the effort, not by sophistication. If you only do the first two and the last one, you’ll have captured most of the available gain.
1. Progressive disclosure: give pointers, not payloads
This is the context engineering technique with the strongest research backing of anything on the list. The ContextBench study, which ran over a thousand tasks across dozens of repositories, found that models consistently favour recall over precision — they pull in far more material than they need and then use a fraction of it.
The practical response is to stop handing the model content and start handing it addresses. Instead of pasting six files into the window, give the agent a file tree and a tool to read any file on demand. Instead of dumping a full schema, give a table list and a lookup tool.
The behaviour change is significant: the model retrieves what the task actually requires, at the moment it requires it, and the window stays small. It also makes failures legible, because you can see exactly what the agent chose to open.
2. Retrieve instead of stuffing
Related but distinct, and the context engineering move most teams already half-implement. Progressive disclosure is about deferring; retrieval is about selecting. If your knowledge base is bigger than a few thousand tokens, it does not belong in the system prompt, no matter how big the window is.
The quality of this depends almost entirely on decisions you made further upstream — how you split documents and which model you embed them with. If retrieval is returning near-misses, the fix is usually in your chunking strategy or your vector database configuration, not in your prompt.
3. Treat compaction as a last resort, not a default
This is the context engineering rule where I’ve changed my mind, and where a lot of published advice hasn’t caught up.
The reflex when a conversation gets long is to summarise it — compact the history into a shorter recap and carry that forward. It seems obviously correct. Fewer tokens, same information.
Except the measured results push back hard. Work from the Towards AI team, running real evaluations on a production tutoring application, found that once prompt caching is in play, keeping the full history is frequently cheaper, faster, and better at recall than summarising it. Compaction throws away detail you didn’t know you needed, and it costs a model call to produce.
The revised rule: compaction should be a deliberate response to a specific named constraint — you’re genuinely about to exceed the window, or you’ve measured a latency problem — rather than something you do automatically because the conversation feels long.
4. Use prompt caching as an architectural decision
Prompt caching changes the economics of context engineering enough that it should shape your design, not just your bill.
The mechanic is straightforward: stable prefixes get cached, and cached tokens are dramatically cheaper on re-read than fresh ones. The design implication is that you want to structure context so the stable parts sit at the front and the volatile parts sit at the back. System instructions, tool definitions, and reference material go early. The turn-by-turn conversation goes last.
Teams that get this ordering wrong shuffle their context on every call, invalidate the cache constantly, and then wonder why caching “didn’t help.” It’s not that caching didn’t work. It’s that nothing was stable enough to cache.
5. Prune the tool set aggressively
Tool pruning is the most neglected context engineering lever there is. Every tool definition you expose sits in the context on every call, consuming tokens and adding a decision the model has to make. And as noted above, larger tool sets measurably degrade performance.
If you’ve connected a dozen MCP servers and the agent now has ninety available tools, you’ve created a confusion problem. The fix is scoping: expose only the tools relevant to the current task or phase, and swap the set as the task moves through stages. A research phase needs search tools. An editing phase needs file tools. It rarely needs both simultaneously.
6. Move memory outside the window
Context engineering for long-running agents runs into a hard limit: they need to remember things across sessions, and the conversation history is a bad place to keep that.
The direction the field is moving is external, structured memory — notes written to files or a store, indexed, and retrieved on demand rather than carried in the window. A large multi-author survey published last year argued that the memory taxonomies borrowed from earlier systems aren’t adequate for agents, and proposed richer models; the A-MEM work demonstrated a Zettelkasten-style approach where the links between memories evolve as new ones are added.
You don’t need a research-grade system to benefit. Even a simple pattern — have the agent maintain a running notes file, and read it at the start of each session — solves most of the practical problem and keeps the window clean.
7. Isolate work in sub-agents
When one agent handles research, planning, and execution in a single thread, all three phases share a context, and the noise from each contaminates the others. Research produces a lot of tokens the execution phase does not need.
Splitting the work so a sub-agent does the messy exploration and returns only a clean summary keeps the main thread’s context tight. This is one of the main structural arguments for the orchestration patterns in most AI agent frameworks — the isolation is the point, not just the parallelism.
8. Feed live data instead of relying on training knowledge
No amount of context engineering saves you from stale inputs. Models have knowledge cutoffs, and agents making real decisions on stale information fail in ways that are hard to spot. Reported figures put hallucination rates substantially higher — on the order of a third higher — on tasks that require current information when the agent has no access to live data.
Anything time-sensitive — prices, availability, current documentation, recent releases — should come from a live lookup at request time, not from what the model absorbed during training. This is the least glamorous item on the list and probably the highest-yield for anything customer-facing.
How to Measure Whether Any of This Helped
Every context engineering technique above is testable, and if you’re not testing them you’re guessing.
Good context engineering is measured, not argued about. Build a small evaluation set from real failures — twenty to fifty cases where your system produced a bad answer, with the correct answer recorded. Then change one thing at a time and re-run. Does full history beat compaction on your data? Does progressive disclosure hurt latency more than it helps accuracy? The answers vary by application more than most write-ups admit, including this one.
When something fails, separate retrieval quality from generation quality before you start tuning. If the right material never made it into the window, no amount of prompt rewriting will save the answer. Metrics like context relevance and answer relevance exist precisely to tell those two cases apart, and tools such as RAGAS and DeepEval automate them with configurable thresholds. Debugging a context pipeline by intuition — nudging parameters and re-reading outputs — is the single most common way teams waste weeks.
Five Context Engineering Mistakes I Keep Seeing
These come up often enough in code reviews that I’ve stopped being surprised by them.
Treating the window size as a target. A million-token window is a ceiling, not a goal. Filling it is almost always a design failure, not an achievement.
Auto-summarising by default. Covered above, but worth repeating because it’s so widespread. Measure before you compact.
Letting errors persist in context. If an agent makes a wrong assumption on turn three, and turn twenty is still reading it, you have a poisoning problem that no model upgrade will fix. Build a way to correct or evict bad context.
Generating context files with AI and never reading them. Auto-generated project summaries and rule files drift from reality fast, and a stale instruction file is a clash waiting to happen. If it’s steering the model, a human should have read it recently.
Doing context engineering before fixing retrieval. If the right chunk isn’t being returned, everything downstream is theatre. Fix the retrieval layer first.
Where This Is Heading
Two things look likely from here. The first is that memory becomes a first-class part of the context engineering stack rather than something each team improvises — the research convergence on this is hard to miss, and the tooling is starting to follow.
The second is less comfortable for anyone hoping context engineering is a passing phase. As models get better at handling long contexts, there’s a real temptation to declare context engineering a temporary workaround that better models will make obsolete. I don’t think that’s right. Attention is finite, tokens cost money, and deciding what matters is a design question, not a capacity question. Bigger models will raise the ceiling. They won’t make curation unnecessary.
The Bottom Line
Context engineering comes down to one question you should be able to answer for every call your system makes: why is each of these tokens here?
If the answer is “because it accumulated,” you have work to do. Start with the two highest-yield context engineering moves — pull live data for anything time-sensitive, and prune your tool set — because they’re cheap and the improvement is usually immediate. Then build a small eval set before touching anything else, so you can tell whether the rest of it is working.
And resist the upgrade reflex. The team I opened with eventually solved their problem, but not with a bigger window. They solved it by cutting their average context to about a tenth of what it had been.
For more practical breakdowns of context engineering and the wider AI tooling stack, see our guides to RAG, agent frameworks, and the full AI tools archive.


[…] on every call, silently erasing the benefit. This is the same principle covered in our guide to context engineering: stable parts of the context belong at the front, volatile parts at the […]