Agentic retrieval-augmented generation (RAG) adds an AI agent to a retrieval-and-generation pipeline. Traditional RAG retrieves relevant external information and passes it to a language model. In agentic RAG, the agent can plan multiple retrieval steps, revise a query in response to results, and choose among search tools before producing an answer. section 14.2
The distinction is control over retrieval, not a particular search algorithm. An agent might search local documents first, then search the web if the local results are not relevant. It can also select different local retrieval methods or use more than one tool for a query. section 14.2
A practical setup gives the agent tools with distinct retrieval jobs:
- BM25 search retrieves local document passages by keyword. section 14.2
- Semantic search embeds a query and searches stored document embeddings in LanceDB. section 14.2
- Hybrid search combines BM25 and semantic retrieval; an EnsembleRetriever can weight their results. section 14.2
- Web search offers another source when local retrieval is insufficient. section 14.2
Local documents and web search
A Python example loads a PDF, splits it into overlapping chunks, and makes those chunks available to BM25 and embedding-based search. A smolagents CodeAgent using SmolLM2-1.7B-Instruct receives search tools and a three-step limit. Queries about smart-home technologies demonstrate local search; further runs illustrate choosing between hybrid local search and web search, or using multiple tools. section 14.2
from langchain.retrievers import EnsembleRetriever
def __init__(self, bm25_retriever, semantic_retriever, **kwargs):
super().__init__(**kwargs)
self.ensemble_retriever = EnsembleRetriever(
retrievers=[bm25_retriever, semantic_retriever],
weights=[0.4, 0.6])
The hybrid-search constructor shows two retrievers combined with explicit weights of 0.4 for BM25 and 0.6 for semantic retrieval. This combination is a search tool the agent can choose, not the agent’s decision process itself. section 14.2
Agentic RAG fits information-gathering tasks such as customer support, research assistance, and knowledge management. Its practical value depends on the available sources and tools: adding an agent enables adaptive search, but does not by itself establish that a retrieved passage is relevant or an answer is accurate. section 14.2



