What is context engineering?
Context engineering designs the information supplied to an AI model, selecting the instructions, documents, and history that each specific request needs.
Context engineering is the design of the information an artificial intelligence model receives when it performs a task. That information includes the user's request, instructions, available documents, conversation history, and, when needed, descriptions of the tools the model can use. Its purpose is to supply relevant, understandable material within the context window, the limited amount of information the model can process. Accumulating documents is not enough: designers must choose what to include, how to order it, and what to retain as a conversation grows. The prompt, the text that instructs the model, is one component of the system; context engineering also addresses the source and selection of the data that accompanies the prompt. Test the choices on the actual task, because information in the context is not necessarily used correctly in the answer. What to supply depends on the question, the available sources, and the way the system retrieves them.
See also: RAGRAG combines search and generation: it retrieves external sources relevant to a question and passes them to a language model, which draws on them to answer.
How it differs from prompt engineering
Prompt engineering focuses on the wording of instructions. Context engineering also considers how information reaches the model and how it changes from one request to the next. For example, RAG retrieves external documents for use in generating an answer. In the original RAG paper, researchers pair a language model with a retriever over a Wikipedia index: the question serves as the search query, and the retrieved passages are added to the input from which the model generates the answer.
Loading everything does not guarantee a better result. Lost in the Middle tested multi-document question answering and key-value retrieval; the models it studied often made better use of information at the beginning or end of a long context than of information in the middle. The finding is experimental and may not hold for every model. The choice between preloaded documents and just-in-time retrieval calls for testing with representative questions, checking relevance and source freshness.
How to evaluate a context setup
Retrieved material can be incomplete, irrelevant, or contradictory. The RGB benchmark examines robustness to documents that relate to the question but lack the answer, refusal to answer when information is missing, integration of multiple sources, and handling of documents with factual errors; the models it evaluated showed some robustness in the first case but struggled markedly with the other three. A useful comparison therefore measures not only correct answers, but also whether the system recognizes a missing source and distinguishes conflicting versions.
An enterprise example
An internal assistant must answer questions about purchasing procedures. The team gives it standing instructions and retrieves the procedure relevant to the question, rather than attaching every policy to every request. If a source is unavailable, the assistant must say so. The project lead compares this approach with a fixed document set on known questions, including some about updated or missing procedures. This is a hypothetical example: quality depends on the organization's sources and tests.
Why it matters for decision makers
Before buying, ask which sources feed the context, how they are updated, and what conversation data is retained. The vendor should be able to show results on real questions, unanswerable cases, and contradictory documents. Buyers can then evaluate the whole solution instead of choosing on advertised window size or model name alone.
Frequently asked questions
Related terms
- RAGRAG combines search and generation: it retrieves external sources relevant to a question and passes them to a language model, which draws on them to answer.
- AI Agents (Agentic AI)An AI agent is a system that uses a model and external tools to select and perform actions toward a goal, within established boundaries and permissions.
- Context windowThe context window is the limit, measured in tokens, on how much information an AI model can use for a request, including the response that the model generates.
- Context RotContext rot is the decline in a language model's answer reliability as its context grows, even when that context fits within the provider's stated capacity.
- Intent engineeringIntent engineering defines an AI agent's objectives, success criteria, and limits on autonomy, so that the mandate it receives is explicit and testable.