LangChain Explores Context Engineering for Agent Retrieval
LangChain’s blog examines three retrieval problems for agents with limited context windows: inefficient searching, excessive context returned at once, and irrelevant or stale information. It presents Deep Agents techniques including filesystem search-before-read tools, paginated file reads, offloading oversized results, delegating reading to subagents, and verifying grounding against retrieved sources.
The article offers concrete retrieval patterns for keeping agent context focused, including searching before reading, returning pointers instead of full payloads, delegating noisy retrieval work to subagents, and checking answers against expected sources.
Key Takeaways
- Agents work with a limited context window, and information retrieval breaks in three ways: inefficient searching, too much context at once, and irrelevant or stale context.
- The Deep Agents harness keeps searches small out of the box. The built-in filesystem tools search before they read: glob matches file names, grep finds matching lines, and read_file reads a page at a time. Oversized tool results are offloaded: the full result is saved to files, but the agent gets just the path and a preview.
- For custom search tools (like RAG), use "retrieve, offload, delegate": save results to files, return the paths, and let subagents read them. The main agent only sees what's relevant.
Imagine you’re taking an open book exam: you technically have all the answers, but somehow that makes it even harder to find the right one.
- Where do you even start searching?
- When do you know that your sources are correct?
- How do you optimize your time so that you don’t blow all your energy on redundant searches?