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 the practice of selecting, organizing, and maintaining the information an AI model receives when completing a task. A model’s context can contain system instructions, the user’s request, conversation history, retrieved documents, database results, tool descriptions, tool outputs, examples, user or organizational preferences, agent plans and task state, and summaries of earlier work. Prompt engineering focuses mainly on how instructions are written; context engineering focuses on the model’s entire informational 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 ComputeTape 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.
Market signal
Context engineering directly affects inference demand. A larger context window lets a model accept more information, but it does not make every token equally useful — context remains a limited attention, latency, memory, and cost budget.
Market read: context-heavy applications can increase recurring inference demand even without more users. Better retrieval, caching, and context control can reduce tokens per completed task and improve throughput. Figures here are illustrative unless explicitly sourced and dated — see our methodology.
The most common mistake is context stuffing: sending every potentially relevant document to the model and expecting it to determine what matters. This mixes current with outdated information, instructions with untrusted content, authoritative with unofficial sources, and completed with unfinished work. A second mistake is letting conversation history grow forever — 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
Use the GPU-Hour Cost Calculator, AI Training Cost Calculator, or Model Serving Cost Calculator.
Compute College track
Step 2 of 2: What is context engineering