Context Engineering
All 12 cards in this deck
The attention budget, the four operations, compaction, caching — what the model sees and why. Answer each question before you open it — then run the review above, which schedules every card with spaced repetition so it comes back right before you would forget it.
Define context engineering in one line.
Curating everything the model sees each step — system prompt, tools, retrieved knowledge, history, memory — and, just as deliberately, what it doesn’t.
Name the four operations of context engineering.
Write (persist outside the window), Select (retrieve what matters), Compress (summarize/trim to budget), Isolate (split across sub-agents).
What is context rot?
Recall and accuracy degrading as the window fills with stale or irrelevant content — attention is a finite budget, not a bucket.
Why does a bigger window not solve context problems?
Middle content is recalled worst, irrelevant text distracts, and every token adds prefill cost and latency. Bigger raises the ceiling, not the quality.
The three taxes on an overstuffed context?
Attention tax (worse recall), cost/latency tax (prefill grows), behavioral drift (the model imitates the accumulated mess).
What is just-in-time retrieval for agents?
Give the agent lightweight references (paths, ids, queries) plus tools to load them when needed — instead of pre-loading everything it might use.
What is compaction?
Summarizing the oldest trajectory into a short digest while keeping recent turns verbatim — recency gets fidelity, the past gets a précis.
Why keep the prompt prefix stable?
Prompt caching only hits on unchanged prefixes — stable system prompt + tools first, volatile content last, collapses prefill cost.
What is system-prompt “altitude”?
The right level of instruction: firm on outcomes and guardrails, silent on micro-steps. Too rigid breaks on edge cases; too vague invites drift.
Why do sub-agents help with context?
Isolation: each worker gets a clean, task-scoped window and returns distilled findings — depth in one lane never crowds another.
What should an agent persist in structured notes?
Objectives, decisions, learned facts and open questions — conclusions, not transcripts; notes compress, raw context expires.
Prompt engineering vs context engineering?
Prompt: “how do I phrase this instruction?” Context: “what should be in the window at this step — and what should not?”