Context Engineering
Context engineering is the design of the information a language model receives at each step of an application. It covers instructions, conversation history, retrieved evidence, tool definitions and state, with the aim of giving the model enough relevant context to act reliably within a finite context window.
What it is
A prompt is one component of context; context engineering also controls how information is selected, represented, refreshed and removed. An application may retrieve documents before a call, expose only tools relevant to the current task, summarize an older conversation, or load a file only when needed. These choices change what evidence and constraints the model can use without changing its trained weights. Long contexts are therefore a resource to manage, rather than a reason to send every available document. For an agent, the process repeats as tool results and intermediate decisions accumulate.
What the work involves
The practitioner specifies a context assembly policy and tests it against realistic tasks. Useful artifacts include a message layout, retrieval rules, a history retention policy, compact state records and a trace showing the material sent on each call. Evaluation should separate missing evidence from evidence the model failed to use. A comparison might keep the model and task constant while changing document selection or summary format. Token cost matters, but preserving an unresolved requirement or a critical exception may justify additional context.
Illustrative example
Consider an assistant investigating an installation failure. It begins with the user's environment, a short troubleshooting policy and the current error. It retrieves the relevant installation guide, then calls a diagnostic tool. After several unsuccessful attempts, it keeps a structured record of commands already tried and their outcomes rather than repeating all terminal output. Before proposing a change, it loads the exact configuration section affected. The context evolves with the investigation instead of becoming an ever longer transcript.
Limits and common mistakes
Compaction can discard a constraint, retrieval can select obsolete evidence, and tool output can contain instructions that conflict with the user's request. Context assembly needs explicit provenance and boundaries between instructions and source material. A large advertised context window does not establish reliable use of every token. Good checks include whether the same requirement survives repeated summarization, whether conflicting sources are surfaced, and whether the model can identify the evidence behind a decision.
Prerequisites
Context engineering is prompt engineering elevated to a discipline — it subsumes prompt design, context selection, and memory management
Context engineering requires understanding how models process long contexts, where attention degrades, and how to structure information
Context engineering explicitly optimizes what goes into the context window — token economics is a core constraint
Related skills
- → is part of: GenAI
- ← is part of: Prompt Caching
- ← is part of: Prompt Engineering
- ← is part of: Prompt Management
- ← is part of: Semantic Routing
- ← is part of: Token Optimization
Sources and further reading
- Effective context engineering for AI agents
Explains context selection, tool design, just-in-time retrieval and compaction as application engineering decisions.
Last updated: 2026-10-10