Just-in-Time Retrieval Over Pre-Loading

Don't fill context with everything that might be relevant — retrieve only what is needed, exactly when it is needed, and discard it after use.

What it is

Pre-loading is the impulse to front-load context with all potentially relevant documents, tools, history, and reference material before work begins. The cost compounds: a large pre-loaded context crowds out working memory, forces the model to attend across irrelevant content, and spends tokens that could hold later-stage results. Just-in-time retrieval inverts the pattern — keep the context minimal at the start, and pull in specific content only at the step that needs it. A code review agent does not need the full API documentation in its context from turn one; it needs the relevant section when it encounters the relevant function. A planning agent does not need every prior conversation; it needs the summary of the last decision. Just-in-time retrieval treats information like a dependency that should be loaded at the moment of use, not pre-declared at the top of the program.

"Memory" is the wrong word for this until it is specified. The grand metaphor — give the agent a memory — invites pre-loading and obscures the actual design decision. The practical question is much narrower: what should this agent know at this moment to improve this outcome? That question reframes the problem as context governance rather than generic memory, and it is the question just-in-time retrieval answers per step. This is also why calling a RAG pipeline "memory" and stopping there is an anti-pattern: retrieval is genuinely useful, but it is only one component of memory. Real memory also requires selection (deciding what to pull), decay (letting stale material expire), correction (fixing what was wrong), and evaluation (checking that the retrieved context actually helped). A retriever with none of those is a lookup, not a memory — and treating it as the whole solution leaves the hard governance work undone.

When to reach for it

When NOT to

Exemplars

Related