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.
What is hybrid search?
Combining keyword search, which finds exact names and codes, with embedding search, which finds similar meaning, then reranking the candidates.
Related concepts
Where the book covers it
- Chapter 13 · 13.1 What the context layer is, and why it matters
- Chapter 13 · 13.6 Retrieval and context engineering