Learning outcomes
- Design a context budget
- Rank information by utility
- Isolate untrusted content
Mental model
Context engineering designs the complete information environment for a model call: selection, ordering, compression, trust boundaries, and lifecycle.
Theory
The system assembles stable instructions, current request, relevant state, retrieved evidence, examples, and tool results under a budget. Every segment should justify its expected utility. Context is refreshed at task boundaries, summarized with provenance, and isolated by trust level. The goal is the smallest sufficient context, not the longest prompt.
Alternatives and trade-offs
Long context retains raw material, retrieval selects external evidence, memory persists state, caching reuses stable prefixes, and fine-tuning moves stable behavior into parameters.
Failure modes and misconceptions
Do not dump full histories, mix instructions with evidence, keep stale summaries indefinitely, or measure only answer quality while ignoring tokens and latency.
Knowledge check
What criteria should determine whether an item enters a model context?
Decision scenario
For incident support, include the active alert, relevant runbook sections, recent approved actions, and current system state; omit unrelated historical logs.
Relationships
Context Windows
Context engineering manages finite model input budgets.
prerequisiteState and Memory
Persistent state must be selected and rendered into context.
prerequisiteExact and Semantic Caching
Caching reuses parts of context construction and model work.
prerequisiteRAG versus Fine-Tuning
Strategy selection starts by diagnosing context and behavior gaps.
Primary sources
- Effective Context Engineering for AI Agents - Anthropic, verified 2026-07-16