Retrieval in Agents

Accessing Information Beyond the Context Window

Retrieval is how agents access information too large, too current, or too specialized to fit in the context window. It addresses three fundamental LLM limits: the context window cap, the training cutoff, and hallucination.

Types of Retrieval

1

Web search — Query a search API (Google, Bing, Tavily), retrieve current web results. Used for real-time information and anything after the training cutoff.

2

Vector search — Embed the query and retrieve semantically similar documents from a vector database (Pinecone, Weaviate, Qdrant). Used for proprietary knowledge bases, internal documentation, and domain corpora.

3

Structured database — Generate and execute a SQL query, or call a structured API. Used when information is structured and the query is specific.

4

File system — Search for and read specific files. Used for codebase navigation, document processing, and data analysis in local or cloud storage.

Retrieval as a Tool

Reactive vs proactive retrieval

Most well-designed agents use reactive retrieval — retrieve on demand, as gaps in knowledge become apparent, rather than front-loading everything at task start. This minimizes context clutter and keeps the context focused on what is currently relevant.

Agents vs Single-Pass RAG

Single-Pass RAG

Retrieve once from the knowledge base, inject results, generate a response. Fixed retrieval — no ability to refine if the first pass misses key information.

Agentic Retrieval

Retrieve, reason about results, determine if more information is needed, refine the query, retrieve again. Iterative and adaptive — continues until the question is answerable.

Need Help?

Ask the AI assistant about retrieval in agents, how to implement vector search as a tool, or how agentic retrieval extends RAG.