Anthropic: Effective context engineering for AI agents
Primary engineering guidance on context as a finite, maintained information environment.
Compute College
Understand the finite input and output budget shared by instructions, history, retrieved data, and model responses.
A context window is the amount of tokenized information a model can use in one request, within the limit set by the provider and model. Instructions, user input, history, retrieved documents, tools, examples, and the answer all compete for that space. A bigger window does not make every token useful.
Memory trick: The context window is a suitcase: every instruction, document, history item, and answer competes for space.
When context is too large, the application may truncate important material, hit a provider limit, increase latency, or spend money on irrelevant text. Reserving output before filling the input side prevents a request from leaving no room for the answer. Context budgeting is therefore an application, reliability, and compute-cost decision.
With a 128,000-token window, 1,200 tokens of instructions, 16,000 tokens of retrieved material, and 2,000 reserved output tokens use 19,200 tokens before history or tools. The remaining budget is not a promise that all 108,800 tokens should be filled; it is room the application can allocate if the task needs it.
Example figures are illustrative calculations, not current quoted market prices.
Current example
Anthropic describes context engineering as curating and maintaining the full set of tokens available to a model, including instructions, tools, external data, history, and agent state. The exact window and pricing depend on the provider and model.
Primary engineering guidance on context as a finite, maintained information environment.
Source discipline: the reference explains the concept or method; it is not a substitute for measuring a production workload under its actual provider, model, and data conditions.
The context limit is a ceiling, not a target. Filling every available token can bury relevant evidence in noise and create avoidable cost. The goal is minimum sufficient context, not maximum context.
Practical takeaway
Use the Context Budget Calculator for one workflow. Record stable instructions, current input, retrieved material, history, tools, and reserved output separately. Set a warning threshold and a fallback when the request exceeds it.
Decision check: when the request exceeds its budget, does the system preserve the information that is authoritative and necessary for the next decision?
Compute College
Use the GPU-Hour Cost Calculator, AI Training Cost Calculator, or Model Serving Cost Calculator.
Compute College track
Step 10 of 18: Context windows and token budgets