Anthropic: Effective context engineering for AI agents
Primary guidance on context compaction, caching, and keeping long-running agent work useful.
Compute College
Reduce repeated context work with summaries, cached prefixes, and reusable state while preserving important evidence.
Context compression removes or summarizes information that is no longer needed while preserving decisions, evidence, constraints, and unresolved work. Caching reuses stable instructions or repeated context where the provider or application supports it. Reuse can reduce repeated processing, but a cached or summarized item must still have a freshness, scope, and invalidation rule.
Memory trick: Compression saves space. Caching saves repetition. Invalidation protects truth.
Many AI applications resend the same system instructions, policy excerpts, history, or tool descriptions on every request. At scale, those repeated tokens create cost and latency. Compression and caching can improve throughput, but an incorrect summary or stale cache can cause a systematic error across many requests.
An agent summarizes a completed research phase into decisions, citations, open questions, and rejected paths. Stable tool instructions are reused for a session, while current prices are retrieved again for each decision. If the policy or permissions change, the cached material is invalidated rather than silently reused.
Example figures are illustrative calculations, not current quoted market prices.
Current example
Anthropic’s context-engineering guidance discusses compaction, summarization, caching, and maintaining useful agent context. The economic impact depends on provider pricing and the application’s repetition pattern, so measure actual cache hits and output quality.
Primary guidance on context compaction, caching, and keeping long-running agent work useful.
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.
Shorter context is not useful if compression removes the evidence or uncertainty needed for the next decision. A concise wrong memory is still wrong.
Practical takeaway
Choose one repeated context block and model three options: resend, cache, or summarize. Record token volume, cache hit rate, summarization cost, latency, and answer quality. Add an explicit invalidation event for every fact that can change.
Decision check: can the system tell whether a context item is current, cached, summarized, and still authorized for this request?
Compute College
Use the GPU-Hour Cost Calculator, AI Training Cost Calculator, or Model Serving Cost Calculator.
Compute College track
Step 17 of 18: Context compression caching and reuse