Agentic RAG
Retrieval becomes a tool, searchDocs(query). The agent decides when to search, and can search several times with different queries.
Last updated
Analogy
Instead of one fixed SQL query per request, the agent writes its own queries until it finds the answer.
Code example
const searchDocsTool = { type: "function", function: { name: "searchDocs", description: "Search the team's engineering docs. Use for how-to and policy questions.", parameters: { type: "object", properties: { query: { type: "string" } }, required: ["query"], }, },};In an agent
This is how RAG and agents meet: retrieval is just one more tool in the loop.
Practice
Flashcards
- What is agentic RAG?An agent that calls retrieval as a tool, as often as it needs.
Questions people ask
What is agentic RAG?
In agentic RAG, retrieval becomes a tool, such as searchDocs with a query argument. The agent decides when to search and what to search for, and it can search several times with different queries until it has enough. Classic RAG instead runs exactly one search before every answer.
When is agentic RAG better than classic RAG?
When questions need several lookups or a rephrased search, like comparing two policies or following up on what the first search found. Classic RAG is cheaper and more predictable for simple question answering. Agentic RAG costs more model calls but handles messy, multi-part questions much better.