Context engineering is the work of deciding what an agent sees. Not just the prompt, which is one part of it, but everything in the window at the moment the model decides: instructions, tool definitions, retrieved documents, earlier turns, and results from tools it already called. At WeAreDevelopers World Congress in San Jose in September, a talk from Osedea organized that work into five pillars. It is the most useful framing of the problem I have come across, because it turns a vague goal ("give the agent good context") into five separate decisions you can make on purpose.
| Pillar | The decision it covers |
|---|---|
| Formatting | What shape the information is in |
| Writing | What lives outside the context, in scratch pads and memory |
| Compaction | What gets shrunk once it has done its job |
| Selection | What is relevant right now, chosen at runtime |
| Isolation | What work belongs to a separate agent |
Formatting and Writing
Formatting is the first pillar on the slide. My reading of it: the same information costs different amounts of attention depending on its shape. A table of fields with types is easier for a model to use correctly than three paragraphs describing the same fields. It is the instinct behind writing specifications precise enough that an assistant builds from them without a clarifying question. Structure is not decoration. It is how you make the important parts unambiguous.
Writing is about what does not live in the context at all. Scratch pads and memory sit outside the window, and the agent writes to them and reads from them when it needs to. The context window is working memory, not storage. Anything the agent needs to keep but does not need to look at right now belongs outside, where it does not crowd out the current task. I described how I split my own assistant's memory by how long a fact stays true in Right Knowledge, Right Lifetime. This pillar is the same idea at the level of a single agent run.
Compaction and Selection
Compaction is shrinking what has already done its job. A tool result that was essential three steps ago is usually dead weight now, because the decision it informed has been made. Keeping the full result in the window means every later step pays for it.
Selection is the inverse: choosing what goes in, at runtime, based on what the current step needs. The talk's sharpest example was tools. Load tool definitions only when they are needed, through a tool-search style gateway the agent asks for the tool it wants, instead of loading every definition up front. The speaker cited a figure from Uber: startup context went from roughly 50,000 to 70,000 tokens to near zero.
That figure is worth a second look. Tens of thousands of tokens of tool definitions is not overhead at the edge. It is a large share of the window, spent before the agent has read a word of the actual task, and every token of it competes for the model's attention with the thing you asked it to do.
Isolation
Isolation means splitting work across agents so that no single context carries everything. A sub-agent gets a bounded task, does its reading in its own window, and hands back a result. The main agent sees the conclusion, not the dozens of steps that produced it.
This is the pattern I wrote about in Go Do X and Report Back, and the tell for when to use it is the same. If the work would flood the main context with material you only need the conclusion of, it belongs to a separate agent. Isolation is also the cheapest of the five to get right, because the boundary is a brief and a report, and both can be written down before anything runs.
One Script Instead of Twenty Calls
One more technique from the talk cuts across several pillars at once: programmatic tool calling. Instead of having the agent make many tool calls one at a time, each with a round trip through the model, let it write one script that makes the calls and returns the result.
Say an agent needs to look up twenty records and count how many meet a condition. Done call by call, that is twenty round trips, with twenty results sitting in the context afterward. Done as one script, it is one call and one number. That is compaction and selection in a single move: the intermediate results never enter the window at all.
There is a second benefit the token count does not show. A script is something you can read. Twenty separate calls are a sequence you have to reconstruct from a trace. One script is the agent's plan, written out, in a form a person can check.
What I Would Do
My take: treat each pillar as a line in the specification for any agent you build, not as a tuning exercise for later. Before the build, write down:
- What the agent loads at startup, and why each item has to be there from the first step.
- What it writes outside the context, and in what structure.
- When old tool results get dropped or shrunk.
- Which tools are loaded on demand instead of up front.
- Which tasks go to a sub-agent, and what each one hands back.
Then measure one number: how much of the window is spent before the agent reads the task. If the answer is most of it, you have found your first fix, and it is not a better model.