Guides

Agentic RAG: retrieval that can decide and recover

By Abdul Asim ·

What is agentic RAG?

Agentic RAG is retrieval-augmented generation where a language model decides how to retrieve, not only what to say. Instead of running one fixed search before every answer, an agent picks a retrieval tool, checks whether the evidence is good enough, and retries, changes approach or hands off when it is not. The answer is still built from retrieved sources: the agent controls the path to them.

How is agentic RAG different from a standard RAG pipeline?

A standard RAG pipeline runs the same steps for every question: embed the query, fetch the top chunks, put them in the prompt, generate. That is predictable and cheap. For one document collection with similar questions, it is often all you need. It breaks when questions need different kinds of lookup, or when the first retrieval comes back thin and nothing notices.

AspectStandard RAGAgentic RAG
Retrieval pathFixed, same for every queryChosen per query by the agent
Data sourcesUsually one indexSeveral tools: vector, keyword, SQL, APIs
Weak evidenceGenerates anywayCan rewrite, retry, widen or stop
ActionsAnswers onlyCan call tools, such as creating a ticket
Cost and latencyLow and stableHigher, varies with the steps taken
DebuggingOne trace shapeMany paths, needs step-level tracing

The pattern rests on an idea from research on combining reasoning with actions: let the model interleave its reasoning with tool calls such as a search, and feed each result back in before the next step. If the agent side is new to you, what an AI agent is covers that loop on its own.

Agentic RAG architecture from a permit search build

The clearest agentic RAG system I have shipped is Permit Signal. Users ask about construction permits and properties in New Jersey. The documented ingestion scope is 3 million permits and 60,000 property records from Socrata and ArcGIS, which I normalized, geocoded into PostGIS and connected with spatial joins.

A property question is rarely one kind of question. "What permits were filed near this address?" is a location problem. "Any roof work on commercial buildings in this town?" mixes meaning with a filter. A permit number is an exact string. One embedding index cannot serve all three well, so the architecture gives the agent several retrievers:

  • Spatial lookup in PostGIS for anything tied to a place or a radius.
  • Semantic search over prepared text for questions phrased in everyday language.
  • BM25 keyword retrieval for identifiers, names and exact terms that embeddings blur.
  • SQL queries for counts, dates and structured filters.

The conversational agent turns the user's message into semantic queries plus location and property filters, sends them to the retrieval layer, and gets back evidence with coordinates. Answer assembly is source-linked: the response points to the records it used, drops map pins, and lets the user export the results. The language model helps word the answer. The retrieval layer supplies the evidence behind it. That split is the most important design decision in the build.

Retrieval decisions: how the agent chooses what to search

In agentic retrieval, the routing decision is made per message. Get it wrong and a perfectly good index returns nothing useful. These rules hold up well:

  1. Extract structure first. Pull places, dates, record types and identifiers out of the question before choosing a tool, and pass them as filters, not as part of the text you embed.
  2. Prefer the narrowest tool that can answer. If SQL can count it, do not ask semantic search to approximate it.
  3. Combine tools when the question is mixed. Apply a spatial filter, then rank by meaning inside that area, rather than hoping one retriever covers both.
  4. Keep the tool list short and each tool clearly described. Every extra tool is another way for the model to pick wrong.

For why keyword and embedding search fail in different ways, see how a vector database fits into RAG. The point here is narrower: once the choice of retriever becomes a model output, it needs the same scrutiny as the answer.

What does self-correcting RAG look like?

Self-correcting RAG means the system checks its own retrieval or draft before the user sees it, and does something different when the check fails. Research systems do this in a few ways. Self-RAG trains a model to retrieve on demand and to critique the passages and its own output with special reflection tokens. Corrective RAG adds a lightweight evaluator that scores the retrieved documents and triggers further actions, such as a web search, when they look weak.

In client systems the recovery steps are usually plainer, and that is fine:

  • Grade the evidence. Before generating, check whether the retrieved records actually address the question. An empty spatial result inside a tiny radius is a signal, not an answer.
  • Rewrite or widen once. Loosen a filter, expand the radius or rephrase the query, then retry. Cap the retries so the loop always ends.
  • Say what was not found. If evidence is still missing, the answer should say so instead of filling the gap from the model's general knowledge.
  • Hand off. In the McKissock sales assistant, unresolved requests trigger a tool that creates a HubSpot support ticket, so the learner leaves with a next step rather than a guess.

Escalation counts as recovery. An assistant that knows when to stop is more useful than one that always produces text.

Where agentic RAG fails in production

More decisions mean more places to be wrong. These are the failures to design against:

  • Wrong tool, confident answer. The agent sends a location question to semantic search, gets loosely related text and answers anyway. Log the chosen tool at every step and evaluate routing as its own metric.
  • Invented filter values. The agent extracts a town name spelled differently from the data and gets zero rows. Validate extracted filters against known values before querying.
  • Runaway loops. Retry logic without a budget turns one question into ten model calls. Set hard limits on steps and tokens per request.
  • Latency creep. Each reasoning step adds a model round trip. Run independent retrievers in parallel and skip planning for simple, recognisable queries.
  • Untraceable answers. If you log only the final prompt, you cannot tell which branch produced a bad answer. Trace every tool call with its inputs, outputs and timings.

Most of these are the familiar production RAG failure modes, multiplied by the number of paths the agent can take. Test them with a fixed question set that covers every query type, and score retrieval separately from the final answer, as set out in LLM evaluation.

When should you use agentic RAG instead of a fixed pipeline?

Use it when questions need different kinds of lookup, when the data lives in more than one system, or when the assistant must act and not only answer. Permit Signal needed four retrievers. McKissock needed retrieval plus a ticketing action. Both justified an agent.

Skip it when one well-tuned retriever handles most questions. Start with a fixed pipeline, measure where it fails, and add agentic decisions only at those points. A router in front of two indexes is often enough. Full autonomy is rarely the goal. A small, bounded set of choices that you can test is.

Key takeaways

  • Agentic RAG lets the model choose retrieval tools, check evidence and recover, while answers stay built from retrieved sources.
  • Mixed questions need mixed retrievers: spatial, semantic, keyword and SQL each cover a gap the others leave.
  • Self-correction can be simple: grade the evidence, retry once with a wider query, admit what is missing, or hand off to a person.
  • Every agent decision is a new failure point, so log and evaluate routing, not only the final answer.
  • Start with a fixed pipeline and add agency where measurement shows you need it.

Let's talk

Let's ship yours.

AI product, automation bottleneck, RAG use case, or operational workflow. Tell me what's slowing your team down, or what revenue you're leaving on the table.

Abdul Asim, AI / LLM Engineer
Agentic RAG: Architecture, Retrieval Decisions, Recovery