Context Engineering
What is Context Engineering?
Context engineering is the practice of designing what information, instructions, tools and memory an AI model or agent receives for each task, so it has what it needs to perform well.
Updated November 2026 · 2 min read
Context engineering is the work of deciding exactly what an AI model or agent sees when it handles a task, including instructions, retrieved documents, tool definitions, history and memory, so it has what it needs and nothing that distracts it. Models only know what is in their training and what they are given at the moment of the request. For business tasks, the second part usually decides whether the answer is right. Context engineering treats that input as something to design, test and maintain.
The term spread quickly in 2025, when prominent practitioners, including Shopify chief executive Tobi Lütke and AI researcher Andrej Karpathy, argued that it better described the real work of building effective AI applications than prompt engineering did. The difference from prompt engineering is scope: prompt engineering focuses on wording instructions. Context engineering covers everything that fills the model's context window.
What goes into an AI model's context
- Instructions: role, goals, rules and output format.
- Retrieved knowledge: documents, records and facts relevant to the task. See retrieval-augmented generation.
- Tool descriptions: which actions are available and when to use them.
- Conversation and task history: what has already happened.
- Memory: facts saved from earlier sessions.
- Examples: demonstrations of good outputs.
- Structured business context: definitions, relationships and rules, such as which products belong to which business unit. See semantic layer.
Context engineering techniques
- Select: retrieve only what is relevant, rather than everything available.
- Compress: summarize long histories and documents. See prompt compression.
- Structure: organize context with clear sections so the model can find what matters.
- Isolate: give sub-agents focused context for their part of a task. See multi-agent systems.
- Order and cache: keep stable content at the start so it can be reused. See prompt caching.
Why more context is not always better
Long context windows tempt teams to include everything. In practice, model accuracy often drops when relevant facts are buried among irrelevant ones, a problem practitioners call "context rot," and every extra token adds cost and latency. Good context is relevant, current and well organized, not just large.
Context engineering example
Consider a hypothetical HR team whose policy assistant gives wrong answers about parental leave. Investigation shows it retrieves policies from every country, including outdated versions, and the model mixes them. The team changes the context: the assistant now identifies the employee's country and employment type first, retrieves only the current policy for that combination, includes the policy's effective date and instructs the model to cite the section it relies on. Accuracy on a test set of 200 real questions rises from 71% to 94%, with no change of model.
Context engineering is a main lever for AI grounding and for controlling LLM cost.
Frequently asked questions
What is the difference between context engineering and prompt engineering?
Prompt engineering focuses on how the instructions to a model are worded. Context engineering covers everything that fills the model's context window: instructions, retrieved documents, tool descriptions, conversation history, memory, examples and structured business definitions. The term spread in 2025 as practitioners argued it better described the real work of building effective AI applications.
Why can adding more context hurt AI accuracy in context engineering?
Models often perform worse when relevant facts are buried among irrelevant ones, a problem practitioners call context rot. Every extra token also adds cost and latency. Good context engineering selects only what the task needs, compresses long histories, structures content into clear sections and gives sub-agents focused context, so the model sees what matters and little else.
Related terms
Retrieval-Augmented Generation (RAG)
Retrieving relevant information so AI answers are based on real sources.
Semantic Layer
Shared business definitions that sit between raw data and reporting tools.
Multi-Agent Systems
Several specialized AI agents working together toward a shared goal.
AI Grounding
Tying AI answers and actions to real, verifiable sources of information.