Context strategies for agents
Context strategies deliberately decide what an agent should see in its limited context window β and what it shouldn't.
The basic problem
The context window is finite, and more content isn't automatically better. Too much irrelevant material dilutes what's really important β similar to a cluttered desk where you can no longer find the one important sheet of paper. Context strategies are deliberate decisions about what's allowed into the context window.
Common strategies
- Just-in-time retrieval: instead of loading all possibly relevant material into the context upfront, the agent fetches specifically what it needs right now β e.g. via RAG or targeted file references instead of whole folders.
- Compaction: when the context window gets tight in a long session, older parts of the conversation are automatically summarized instead of deleted entirely.
- Subagent architecture: expensive intermediate steps (e.g. a long research task) run in a subagent's context; the main context only gets the finished result.
- External memory: notes or intermediate results are written to files instead of held in the context window β the agent reads them back in specifically when needed.
Why this matters
Anthropic's engineering team explicitly describes context management as its own discipline ("context engineering"): it's not just about providing as much knowledge as possible, but the right, relevant knowledge at the right time β with a high signal-to-noise ratio.
EXAMPLE
Instead of loading the entire codebase into a coding agent's context upfront, it specifically searches for the relevant files when needed and reads only those β the rest stays outside the context window until it's actually needed.
QUICK QUIZ
Why isn't 'load in as much context as possible' a good context strategy?
SOURCES
- Anthropic Engineering: Effective context engineering for AI agents β www.anthropic.com
- Claude-Doku: Tipps fΓΌr lange Kontexte β docs.claude.com