Context engineering
Deciding exactly which tokens the model sees at each step: instructions, retrieved data, tool results, memory and history. Context is a finite budget.
Evolving: the basics hold, details shift. Reviewed 17 Oct 2026.
Key ideas
- Keep the system prompt at the right altitude: specific enough to guide, general enough not to be brittle.
- Load information just in time through tools (search, read file) instead of stuffing everything up front.
- Compaction: summarise old turns and drop stale tool output in long-running agents.
- Trim tool results: return IDs and summaries, let the agent fetch detail on demand.
- Structured notes or scratchpad files give agents memory beyond one context window.
- Sub-agents with clean contexts can explore and return a condensed result.
Common mistakes
- Context rot: accuracy falls as irrelevant tokens accumulate, well before the window is full.