Context engineering
The discipline of what goes in the window, in what order, and what gets compacted away — because the context is the agent's entire reality.
If retrieval is how the right information gets in, context engineering is the craft of arranging everything that is already in — and deciding what to leave out. The context window is the agent's entire reality at decision time, so curating it is not a formatting chore; it is the main lever on behaviour.
Start here
The model sees one flat sequence and nothing else. Everything it can possibly act on is in there, and everything not in there does not exist to it. Context engineering is deciding, for every token, whether it earns its place — and where it sits.
Compact the transcript — keep the last steps raw
summarised (5 steps)
"Found 3 duplicate charges for a Gold customer; refund of 420 is policy-allowed and confirmed."
Compaction trades detail for room: the summary keeps the conclusion but drops the raw evidence, so a later question that needs the exact rows may be unanswerable. The trick is to compact what no longer matters and keep raw what might. Counts are illustrative.
Slide how many recent steps stay raw and watch the transcript trade detail for room.
The moves
- Compaction — summarise old steps and drop the raw transcript once its conclusion is recorded. Keeps the loop affordable over long runs.
- Pruning — remove verbose tool outputs, failed attempts, and duplicates that no longer inform the current decision.
- Ordering — position matters: recall is strongest at the start and end of the prompt and weakest in the middle, so the instructions and the freshest facts belong at the edges.
- Caching — a stable prefix (system prompt, tool schemas) can be cached by the provider and reused across calls, cutting cost and latency without shrinking the window.
Careful
Compaction loses detail by design, and the detail it drops may be exactly what a later question needs. Compress the parts whose conclusions are settled; keep raw the parts that might be re-examined. And test it — a summary that reads well can still have thrown away the number the answer depended on. The window is not free real estate: every token is paid for on every step.
Check yourself
Eduspheria wiki · Agentic AI, Memory & context
0 / 4 answered
That is memory: what the agent knows, where it lives, and how it gets back into the window. Next, what happens when the work needs more than one agent.