Context Engineering for Agents
Why prompt-level context tricks stop working past turn 20, and what replaces them: tool design, compaction, sub-agent isolation, and just-in-time retrieval
The capstone application of context engineering to the hardest case a practitioner faces: a long-running, tool-using agent instead of a single prompt. Covers why agents break naive context management (monotonic growth, unpredictable tool-output size, compounding cost and error), how to write system prompts that hold up over 100+ turns, why tool names/descriptions/schemas are prompt text with a per-turn cost, compaction and structured handoff between context windows, sub-agents as context isolation, just-in-time retrieval versus pre-loading (the Claude Code model), where steering files like CLAUDE.md fit, and how to evaluate agent context strategies with a worked 50-turn token-budget trace.
Practice questions (5)
-
View →
A Coding Agent Degrades Badly Somewhere Around Turn 60
Advanced · Free -
View →
Rewriting a Rule-List System Prompt for a Long-Running Agent
Advanced -
View →
Pre-Loading vs Just-in-Time Retrieval for a New Agent Feature
Advanced -
View →
Deciding What Crosses a Sub-Agent Boundary
Intermediate -
View →
Evaluating Two Context Strategies for the Same Agent Task
Intermediate