Beyond Fixed Pipelines
Standard RAG follows a fixed pipeline: retrieve then generate. Agentic RAG gives the LLM agency to decide its own retrieval strategy. The agent can choose which tools to use, when to retrieve, what to search for, and whether to retrieve again if the first results are insufficient.
How It Works
The LLM is given access to tools: vector search, SQL query, web search, calculator, API calls. For each question, the agent reasons about which tools to use and in what order. It can chain multiple retrievals, combine results from different sources, and self-correct.
# LangGraph Agentic RAG
from langgraph.prebuilt import create_react_agent
tools = [
vector_search_tool, # search docs
sql_query_tool, # query database
web_search_tool, # search the web
calculator_tool, # math operations
]
agent = create_react_agent(
model=llm,
tools=tools,
prompt="You are a research assistant..."
)
# Agent decides: search docs first,
# then query SQL for numbers,
# then calculate the final answer
result = agent.invoke({
"messages": [("user", "What was our revenue growth rate compared to the industry average?")]
})
Agentic RAG is the most powerful but least predictable pattern. The agent may take unexpected paths, make unnecessary tool calls, or get stuck in loops. Use it for complex research queries where flexibility matters. For simple Q&A, stick with fixed pipelines — they are faster, cheaper, and more predictable.