Concept

Context engineering

Last updated

Also called: retrieval, RAG, retrieval-augmented generation

Context engineering is the discipline of deciding what information an AI step sees and in what form. Anthropic's applied AI team frames the goal as finding the smallest set of high-signal tokens that makes the desired outcome most likely; the techniques range from putting small knowledge bases in the prompt to retrieval-augmented generation with hybrid search and reranking.

Why it matters

Output quality depends more on the inputs than on clever prompt wording. Too little context produces generic text; too much buries the important facts, because models use long inputs unevenly, as research on long contexts shows.

Worked example

A reply-drafting agent needs the persona list, the objection taxonomy, and approved proof points. The first two are small and go in the prompt in full. Proof points are retrieved per reply with hybrid keyword and embedding search, reranked, and only the top few are included, with the most important material placed first.

Common mistakes

  • Stuffing everything into a long prompt because it fits.
  • Relying on embedding search alone and missing exact terms such as product names.
  • Chunking documents without the context needed to interpret each chunk.
  • Never evaluating retrieval quality separately from the final output.

Questions

When is retrieval-augmented generation needed?

When the knowledge is too large to include in full. Retrieve the relevant passages at run time and include only those.

Combining keyword search, which finds exact names and codes, with embedding search, which finds similar meaning, then reranking the candidates.

Where the book covers it

Sources for this page

  1. Effective context engineering for AI agents · Anthropic (Applied AI team) · 2025-09-29 · last verified 2026-11-27
  2. Lost in the Middle: How Language Models Use Long Contexts · arXiv (Liu et al., TACL 2024) · 2023-07-06 · last verified 2026-11-27