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 · 5 min read


When people first started working with language models, much of the attention went to prompt engineering: finding the right wording to get a good answer. As AI systems became agents that work through multi-step tasks, use tools and draw on company data, it became clear that wording was only a small part of the problem. What matters more is what the model can see at each step: the instructions it has been given, the documents and data it has retrieved, the results of earlier tool calls, the history of the conversation and the tools available to it. Context engineering is the discipline of designing all of this deliberately.

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 core insight is that models perform best when given exactly the information they need, in a clear form, without irrelevant material that distracts them or wastes capacity. Too little context leads to guessing; too much leads to confusion, higher costs and slower responses. For AI engineers, product teams, knowledge managers and anyone building agents on business information, context engineering has become a central skill.

Definition of Context Engineering

Context engineering is the design and management of everything placed in a model's context window for a given task, including system instructions, user input, retrieved documents and data, tool definitions and results, conversation history and memory, selected, structured and compressed so that the model can reason and act accurately and efficiently.

It works within the limits of the context window, relies on AI grounding and is central to building effective AI agents.

Elements of Context

Instructions. The role, goals, rules and output format the model should follow.

Retrieved knowledge. Documents, records and facts retrieved for the current task.

Tools. Descriptions of the functions the model can call, and the results of calls already made.

History and memory. Relevant parts of the conversation or task so far, and information saved from earlier sessions.

Business context. Structured information about the organization, such as goals, teams, products and policies, often drawn from a knowledge graph.

Context Engineering Techniques

Selection. Choosing only the information relevant to the current step, rather than including everything available.

Structuring. Organizing context clearly, with labeled sections, so the model can find what it needs.

Compression. Summarizing long histories or documents to keep essential information within limits.

Isolation. Giving separate agents or steps their own focused context instead of one large shared context.

Persistence. Saving important information to memory or files so it can be retrieved later rather than kept in context at all times.

Importance of Context Engineering in Enterprise Operations

It improves accuracy. Models given the right information make fewer mistakes and fewer unsupported claims. Many errors attributed to the model are really caused by missing or misleading context.

It controls cost and speed. Focused context uses fewer tokens, reducing cost and response time. This becomes significant when agents make many calls per task.

It also makes business knowledge usable. Well-organized context about the organization lets agents act in line with its goals, policies and structure.

Context Engineering and Financial Management

Model costs depend heavily on the number of tokens processed, so lean context can reduce costs significantly.

Techniques such as prompt caching lower the cost of context that repeats across requests.

Investing in well-structured knowledge and business data improves context quality across many AI applications. A knowledge graph or semantic layer built once can serve every agent that needs business context.

Measuring tokens per task alongside quality shows whether context changes improve efficiency.

Common Challenges

Teams include too much information, assuming more context is always better, which can degrade performance and raise costs. Models can lose track of important details when they are buried among irrelevant material.

Relevant information is missing because it is scattered or poorly organized. If business knowledge cannot be retrieved reliably, even the best-designed context will have gaps.

Long-running agents accumulate cluttered context over many steps, leading to confusion and errors. Old tool results and abandoned approaches remain in context and distract the model from the current step.

Context design is treated as an afterthought rather than a core part of building AI systems. Teams spend weeks choosing models and little time deciding what those models will see.

How to Practice Context Engineering

Practicing context engineering involves understanding what each task needs, building reliable sources of context, selecting and structuring information carefully, managing context over long tasks and measuring the results.

Treating context as a designed product, with owners and tests, leads to more reliable AI systems. Changes to context should be reviewed and tested like changes to code.

Designing Context

For each task or agent step, list the information, instructions and tools the model truly needs. Start small and add information only when tests show it improves results.

Build reliable sources for business context, such as knowledge bases, semantic layers and knowledge graphs.

Write clear, specific instructions and tool descriptions, and keep them consistent across agents. Tool descriptions matter as much as instructions, since they tell the model when and how to use each tool.

Structure context with clear labels and put the most important information where the model will use it. Labeled sections, consistent formats and short summaries make information easier for models to use.

Managing and Measuring

Summarize or prune history in long tasks, and use memory or files for information needed later. Agents can write notes to files and read them back when needed, keeping the working context short.

Split complex work across focused agents or steps when a single context becomes too large. Each agent then sees only the information relevant to its part of the work.

Test changes against a set of representative tasks, measuring quality, cost and speed. Small changes to context can have large effects, so testing should be routine.

Examples of Context Engineering in Practice

The examples below show context engineering in practice.

Both use illustrative figures. The first improves a support agent, and the second improves a planning assistant.

In each, better context mattered more than a bigger model.

Improving a Support Agent

A software company's support agent receives the full product manual with every request and often gives vague answers.

The team changes the design so the agent receives only relevant manual sections, the customer's plan and recent tickets, with clear instructions for escalation.

Answer accuracy improves, average cost per conversation falls by more than half and escalations become more appropriate.

Improving a Planning Assistant

An AI assistant helping managers prepare quarterly plans gives advice that ignores company priorities.

The team adds structured context from the company's knowledge graph, including current goals, the manager's team, its initiatives and budget, to each request.

Recommendations now reference the right goals and constraints, and managers use the assistant far more often.

Conclusion

Context engineering designs what instructions, knowledge, tools, history and business context an AI model receives for each task. Techniques include selection, structuring, compression, isolation and persistence.

In enterprise operations, context engineering improves accuracy, controls cost and speed and makes business knowledge usable. Defining what each task needs, building reliable context sources, structuring information clearly, managing long tasks and testing changes help organizations practice it well.