promptgarten 🌱
🌍 ES
Concept●●●5 min Β· +40 XP

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

RELATED TOPICS

Context Window ●○○Pattern: Feed Context Instead of Asking Vaguely ●○○What Are Subagents? ●●○RAG (Retrieval-Augmented Generation) ●●○