Intermediate · Systems
Context Retrieval Strategy
Visual diagram · (in preparation) · Math · (in preparation) · Worked example · 3 difficulty levels.
TL;DR. The policy that decides what to fetch into context, from where, how much, and when during an agent's loop.
Technical Definition
The policy that decides what to fetch into context, from where, how much, and when during an agent's loop.
How it works
A retrieval strategy chooses between eager retrieval (fetch everything up front) and just-in-time retrieval (let the agent call a search tool when it notices a gap), and combines lexical, vector, and structured queries. Beyond the query, the strategy sets chunk size, result count, deduplication, re-ranking, and recency weighting, and decides whether to inject raw passages or a synthesised digest. In agentic settings, just-in-time retrieval usually outperforms eager stuffing because relevance is only knowable once the agent has started reasoning.
Related Concepts
- Agentic Context Strategies — The repertoire of techniques for filling an agent's window: retrieval, summarization, scratchpads, sub-agents, and offloading to files.
- Agent Memory — Information an agent retains beyond the current context window — episodic history, learned facts, preferences, and task state.
- Context Management — The engineering practice of controlling what goes into a model's context window, in what order, and at what cost.
- Retrieval augmented generation (RAG) — LLMs that can access and use external information to improve their responses.