# Context engineering

> Concept page from *The GTM Engineering Handbook* by Jared Waxman (GTM Engineer School).  
> Web version: https://gtm-engineer-school.com/resources/gtme-handbook/concepts/context-engineering/  
> Last updated: 2026-11-27  
> © 2026 Jared Waxman. All rights reserved. Short quotations with attribution and a link are welcome.

**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](https://www.anthropic.com/research/effective-context-engineering-for-ai-agents) 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](https://arxiv.org/abs/2307.03172) 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

- [Context layer](https://gtm-engineer-school.com/resources/gtme-handbook/concepts/context-layer.md)
- [LLM evaluation](https://gtm-engineer-school.com/resources/gtme-handbook/concepts/llm-evaluation.md)
- [Prompt injection](https://gtm-engineer-school.com/resources/gtme-handbook/concepts/prompt-injection.md)
- [Human-in-the-loop](https://gtm-engineer-school.com/resources/gtme-handbook/concepts/human-in-the-loop.md)

## Where the book covers it

- [Chapter 13 · 13.1 What the context layer is, and why it matters](https://gtm-engineer-school.com/resources/gtme-handbook/context-layer.md)
- [Chapter 13 · 13.6 Retrieval and context engineering](https://gtm-engineer-school.com/resources/gtme-handbook/context-layer.md)

## Sources for this page

- [Effective context engineering for AI agents](https://www.anthropic.com/research/effective-context-engineering-for-ai-agents). Anthropic (Applied AI team). 2025-09-29. Last verified 2026-11-27.
- [Lost in the Middle: How Language Models Use Long Contexts](https://arxiv.org/abs/2307.03172). arXiv (Liu et al., TACL 2024). 2023-07-06. Last verified 2026-11-27.

---

All concepts: [concepts.md](https://gtm-engineer-school.com/resources/gtme-handbook/concepts.md) · Practitioner questions: [questions.md](https://gtm-engineer-school.com/resources/gtme-handbook/questions.md) · All chapters: [llms.txt](https://gtm-engineer-school.com/resources/gtme-handbook/llms.txt)
