LangChain has outlined a retrieval pattern for agents that limits how much raw material enters the main model’s context. Its Deep Agents harness searches narrowly, moves large results into files and lets subagents inspect those files before returning selected facts.
For local information, the recommended sequence is to match file names, search exact text and read only the relevant pages. Semantic retrieval is reserved for queries where the wording is uncertain. Results larger than roughly 20,000 tokens are automatically written to storage, leaving the agent with a path and short preview instead of a context-filling payload.
The same approach can be applied to custom retrieval systems. A search tool writes each result to a file, specialist subagents review one file apiece, and the main agent receives only grounded conclusions and source links. LangChain calls the pattern “retrieve, offload, delegate.” Current web search or date filters are still needed because delegation cannot make stale material current.
The company also warns that retrieved pages are untrusted data and may contain prompt injection. Developers should verify citations and compare generated claims with the underlying sources. The practical goal is not simply more context, but enough relevant evidence to complete the task without allowing noisy or malicious material to dominate the agent’s working window.