Context engineering: the right information at the right moment
Context engineering is the practice of choosing and organizing everything that goes into a model's context window on each call: instructions, tool definitions, documents, memory and history. It extends prompt engineering, which falls short for agents working on long tasks.
Data as of October 22, 2026
Key figures
| Level | Advanced |
|---|
Definition
Put simply: at any given moment, a model only knows what is in its context window. Context engineering is the craft of filling that window with what helps, and nothing else. In its guide published in September 2025, Anthropic defines it as the set of strategies for curating and maintaining the optimal set of tokens during inference, with a guiding principle: find the smallest possible set of high-signal tokens that maximizes the likelihood of the desired outcome.
Why prompt engineering is no longer enough
An agent that runs through many steps piles up tool results, files it has read and back-and-forth messages. Context behaves like an “attention budget”: every added token draws on it, and recall accuracy drops as the context grows. The challenge is no longer just phrasing the initial instruction well, but managing everything that accumulates afterward. To get a feel for the scale, try our context window tool.
Main techniques
- Just-in-time retrieval: rather than preloading everything, the agent keeps lightweight references (file paths, URLs) and opens content when needed, through its tools or an MCP server.
- Compaction: summarize the history as the limit approaches, then continue from the summary.
- Structured note-taking: the agent writes notes outside the context and reads them later, a form of agent memory.
- Sub-agents: specialized agents each work with a clean context and return only a condensed summary to the lead agent.
- Document selection: RAG injects only the relevant passages.
A concrete example
An agent tasked with migrating an application to a new version of a library first reads the list of files, not their contents. It writes its plan in a tracking file, delegates the analysis of each module to a sub-agent, and keeps only the conclusions in its own context. When the history grows, it compacts it. The result: even after many steps, its original instructions stay sharp.
Common misconceptions
- “More context, better answers.” Beyond what is needed, noise reduces accuracy and raises costs.
- “It’s just a new name for prompting.” The prompt is only one part: tools, memory and history often weigh more.
- “A long-context model is all you need.” It pushes the limit back without removing the need to curate.
Related terms: long context, agent memory, RAG, MCP.
Related terms
- Prompt engineering · The practice of writing, testing and refining instructions to an AI model so its answers become more reliable and useful.
- Context window · The maximum amount of text (in tokens) a model can read and produce at once, including its own answer.
- Agent memory · The mechanisms that let an AI agent store, retrieve and update information beyond a single request or conversation.
- RAG (retrieval-augmented generation) · A technique that first retrieves relevant passages from your documents, then hands them to the model so its answer is based on them.
- Long context · A model's ability to process very long inputs in one go, such as books or code repositories, and the techniques that make it possible.
- Model Context Protocol (MCP) · An open protocol that standardises how AI applications connect to external tools, data sources and services.
Try it
Full glossary
Frequently asked questions
How is it different from prompt engineering?
Prompt engineering focuses on writing good instructions. Context engineering manages the whole set of tokens presented to the model across multiple turns: instructions, tools, external data and history. Anthropic describes it as the natural progression of prompt engineering.
Doesn't a large context window solve the problem?
Not entirely. Anthropic describes context rot: as the context grows, the model's ability to accurately recall information from it decreases. A bigger window pushes the limit back without removing the need to curate.
What is compaction?
Compaction means summarizing a long conversation's history as it approaches the context limit, then continuing from that summary plus the most recent items. The agent keeps the thread without dragging along every detail.
Do I need to be a developer to care about this?
The advanced techniques mostly concern developers. But the principle helps any user: give an assistant the documents it needs, remove what it doesn't, and start a fresh conversation when one has grown too long.
Data sources
Data as of October 22, 2026
Report an error
Does a figure, a date or a fact look wrong? Tell us: every report is checked.