Module 3 of 6 · Advanced · 8 min read
Context engineering
Managing what the agent sees across long runs: the skill that separates demos from products.
- 1Long contexts degrade as stale information piles up.
- 2Summarise, prune and store notes outside the context.
- 3Sub-agents with clean context handle focused subtasks better.
01Context rot
Even million-token windows fill up on long agent runs. As old tool outputs accumulate, the model attends less well to what matters, forgetting constraints or repeating work.
Context engineering is the discipline of curating what is in the window at each step.
02Techniques
Combine these depending on the length and shape of the task.
- Compaction: summarise older turns when the context gets long.
- Notes files: have the agent write progress and decisions to a file it can re-read.
- Just-in-time retrieval: load documents when needed rather than up front.
- Tool result clearing: drop raw outputs once their key facts are recorded.
- Sub-agents: delegate a focused task to a fresh agent and keep only its summary.
03System prompts that age well
Keep the system prompt focused on durable guidance: goals, principles, tool usage and stop conditions. Avoid long lists of brittle if-then rules; explain the reasoning so the model can handle new situations.
Finished reading?
Mark it complete to track your progress, then test yourself with the AI Agents quiz.