Anthropic: effective context engineering for AI agents
Official engineering guidance on curating and maintaining an agent’s full context, not just its prompt.
Compute College
How AI systems select and manage the information a model receives before making a decision.
Context engineering is deciding what information an AI model should receive, how it should be organized, and when it should be updated for a task. That context can include instructions, the user’s request, history, retrieved documents, database results, tools, examples, preferences, agent state, and summaries. Prompt engineering focuses on the instructions; context engineering covers the model’s whole working environment.
Memory trick: Prompt engineering writes the instructions. Context engineering prepares the model’s workbench.
An AI model can only make decisions using the information available in its current context. Missing context can make a model use the wrong definition, misinterpret internal terminology, overlook a policy, repeat completed work, select the wrong tool, or produce an answer unsupported by available evidence. Too much context creates the opposite problem: large amounts of irrelevant or outdated information consume tokens and can make important details harder to identify.
Imagine an AI customer-service agent handling a refund request. It may need the customer’s order, the current refund policy, the delivery status, previous messages about that order, and the actions it is authorized to perform. It probably does not need every order placed by every customer, the company’s entire policy library, unrelated conversations, old versions of the refund policy, or tool outputs from previously completed tasks.
Example figures are illustrative calculations, not current quoted market prices.
Current example
Anthropic’s engineering guidance frames context engineering as broader than prompt writing: curating and maintaining the full set of tokens and information available to the model, including system instructions, tools, external data, message history, and agent state. Treat it as a terminology and practice reference rather than a measurement of any particular workload.
Official engineering guidance on curating and maintaining an agent’s full context, not just its prompt.
The Compute College lesson on the limited budget every piece of context competes for.
How multi-step agent tasks turn context decisions into repeated inference demand.
Source discipline: caching, long-context pricing, and retrieval behaviour differ by provider and are not implemented identically. Check the provider’s current documentation before assuming a cost effect.
Context stuffing sends every potentially relevant document to the model and expects it to determine what matters. This mixes current with outdated information, instructions with untrusted content, authoritative with unofficial sources, and completed with unfinished work. Letting conversation history grow forever causes a similar problem: old messages and tool outputs go stale while still consuming tokens on every new step.
Practical takeaway
Build context in layers — stable instructions, the current task, authoritative knowledge, runtime state, tool results, and durable memory — and use retrieval to select relevant information rather than loading everything.
Decision check: good context contains everything necessary for the next decision — and as little unrelated information as possible.
Side by side
Prompt engineering remains part of context engineering. A well-written prompt cannot compensate for missing evidence, and excellent source material cannot compensate for unclear instructions.
| Prompt engineering | Context engineering |
|---|---|
| Designs the instructions | Designs the complete information environment |
| Often focuses on one request | Often operates across many steps |
| Specifies the task and output | Selects instructions, data, history, tools, and state |
| Primarily edits wording and structure | Retrieves, adds, summarizes, caches, and removes information |
| Important for chats and single calls | Essential for agents and long-running workflows |
Compute College track
Step 9 of 18: What is context engineering