Skip to content

Glossary

Context engineering

Context engineering is the design of what information and instructions a model receives for a particular task.

Context engineering

Context engineering concerns the selection, organization, and presentation of material supplied to a model at inference time. That material can include the user's question, governing instructions, retrieved passages, structured facts, and prior interaction. The term names a design problem rather than a single algorithm. A larger context is not automatically better: relevance, authority, timing, and the model's ability to use the supplied material all affect the result.

A sound practice states the task and the authority of each supplied item, keeps source boundaries visible, and tests whether the model uses the right evidence. Selection may involve retrieval, ranking, truncation, and formatting, with checks for omitted or conflicting material. Sensitive content and access permissions must be considered before inclusion. Stable identifiers and source locators make a generated statement easier to trace back to an underlying record.

For an organization defending each value, context engineering determines what evidence a model can consider, but it does not certify the evidence or the answer. Grounding and sentence-level citations provide observable links; faithfulness evaluation tests whether those links support the generated claims. Retrieval-augmented generation is one way to supply context, while the broader problem also includes task instructions, temporal scope, and the treatment of unresolved conflict.

Example

A question about Halden Therapeutics AG (fictional) includes the dated licence excerpt, its locator, and the requested assessment date as model context.

What belongs in the context

A model answers from what it is shown. The context for a call can include instructions, the user's request, the conversation so far, retrieved documents, tool outputs, structured records and examples. Anthropic's engineering note on effective context engineering for AI agents frames the discipline as curating and maintaining the set of tokens supplied to the model at each step, since the budget is finite and every item competes for the model's attention. The original retrieval-augmented generation work showed that supplying retrieved passages could improve knowledge-intensive tasks, and later surveys such as Gao and colleagues catalogue the many variations in how retrieval, ranking and assembly are done.

The decisions are concrete. Which sources are eligible for this user and this question? How are passages selected and ordered? What is quoted verbatim and what is summarised? How are source identifiers and dates carried into the prompt so that the answer can cite them? What is excluded because the user may not see it? Each choice affects what the model can say and what a reviewer can later verify.

Failure modes that engineering can address

Several failures have been documented. Long contexts are used unevenly: the study Lost in the Middle found that models answered best when the relevant passage was at the start or the end of the context and worse when it sat in the middle. Retrieval can miss the right passage, or return it without enough surrounding text to be understood; the paper Seven Failure Points When Engineering a Retrieval Augmented Generation System lists such points from practice, among them missing content, answers present in the retrieved material but not extracted, and answers in the wrong format or of the wrong specificity. Compressing context to fit a budget can discard the qualifier that mattered, as the article on context compression and evidence loss tests.

Design for inspection. Log what was in the context for each answer, with identifiers and versions of the sources. This is the context-side form of provenance, and without it, an answer that turns out wrong cannot be traced to a retrieval fault, a source fault or a generation fault. The article on RAG fault isolation describes how to separate those causes once the logs exist.

A worked example

An assistant answers questions about the contracts of Halden Therapeutics AG (fictional). A user asks about the notice period in a supply agreement. Context assembly proceeds as follows. The access layer first removes any contract the user may not read, as described under need-to-know access. Retrieval returns the clauses of the agreement and an amendment, ranked by relevance. The assembler keeps the original clause and the amendment together, in date order, with their document identifiers and effective dates, instead of letting a summariser merge them. The instructions tell the model to cite clause numbers and to state when the context does not answer the question. The log records every identifier shown. When a reviewer later finds the answer wrong because the amendment was omitted, the log shows that it was never retrieved, and the fix is in retrieval and not in the prompt.

Checks a reviewer can run

Pick ten answers and reconstruct their contexts from the log. For each, ask whether the evidence needed was present, whether anything misleading was present, and whether anything unauthorised was present. Ask what happens when nothing relevant is retrieved. Ask how long contexts are ordered and trimmed. Run the same question with the key passage moved from first to middle and see whether the answer changes, as in the article on long-context robustness to evidence position.

Related terms and boundaries

Context engineering includes retrieval-augmented generation and extends beyond it to instructions, tools and memory. It operates within the context window, uses chunking, vector search and reranking to select material, aims at grounding, and is bounded by need-to-know access.

Common misreadings

  • Assuming more text always improves an answer.
  • Mixing authoritative records with unlabelled commentary.
  • Supplying evidence that the requester is not allowed to see.

Found an error on this page? See corrections for what counts as one, how to report it and the dated log.

Enquiry

Where does "Context engineering" bear on a decision of yours?

This entry sits under context engineering. If a decision in your organization turns on it, send the entity concerned, the sources you fuse to describe it and who may read which of them. We reply with what a first record would cover.

Or write to [email protected] in your own words.