Skip to content
Ali Hassan, home

Blog6 min read

Agentic RAG: what it is and when it pays

Agentic RAG lets the model decide when to retrieve, rewrite a query and check its own answer. See how it differs from plain RAG and when it is worth the cost.

By Ali Hassan, Senior engineer for SaaS and AI products

Agentic RAG puts an agent in charge of retrieval: the model decides when to search, rewrites the question into better queries, calls tools and checks its draft before it replies. That lets it answer questions a fixed pipeline misses, but every extra round is another model call and another wait. Here is how it differs from plain RAG, when it pays for itself, and how to evaluate and cap it.

What is agentic RAG?

Agentic RAG is retrieval-augmented generation with an agent in charge of the retrieval. Instead of running one fixed search and answering, the model decides whether to retrieve at all, rewrites the question into better queries, can call tools, and checks its own draft before it replies. The loop can run more than once, until the answer is good enough or it gives up.

The idea builds on published patterns. Self-RAG trains a model to decide when to retrieve and to critique what came back. The broader survey of agentic RAG catalogues the designs teams now run. The original approach, plain retrieval-augmented generation from a 2020 paper, did a single fixed lookup and left the model no say in it.

RAG vs agentic RAG: how they differ

Plain RAG is a straight line: embed the question, fetch the top matches, put them in the prompt, and answer. Agentic RAG turns that line into a loop the model controls. It can skip the search when it already knows the answer, search again with a reworded query when the first hit is weak, draw on more than one source, and hold its reply back until its own check passes.

The fixed pipeline is the one I lay out in RAG architecture, and it still works the way the 2020 retrieval-augmented generation paper described: one retrieval, one generation, no second-guessing. The difference is not the parts but who drives them. In plain RAG the code decides the steps; in the agentic version the model does, and pays a model call for every decision.

When is agentic RAG worth the cost and latency?

It is worth it when a single retrieval genuinely is not enough: a question that needs facts from several documents, a vague query that only works once reworded, or an answer that must be checked before anyone trusts it. Each extra round the agent runs is another model call you pay for and another wait the user sits through, so the accuracy it buys has to be real.

Those calls are not free, and they add up on a growing prompt. As of 8 October 2026, Claude Sonnet 5.5 costs $2 per million input tokens and $10 per million output tokens, and a loop that retrieves three times runs the model at least three times, each time on a longer prompt. It earns the extra cost in the cases a single search fails: questions that span several documents, exact terms one query misses, and high-stakes answers where a wrong reply is worse than a slow one.

When is plain RAG the better choice?

Most features are better off with plain RAG. If one good search answers the question, a loop only adds cost, latency and more ways to fail. Anthropic's advice on building agents is to start with the simplest thing that works and add moving parts only once they earn their place, which in 2026 still makes a fixed pipeline the right default for a new feature.

A plain pipeline with hybrid search and a relevance floor already answers the large majority of support and document questions. I built exactly that in Evoriqa: semantic and keyword search ranked together, scoped per tenant, with a fixed reply when the knowledge base holds nothing good. It is not agentic, and for most questions it does not need to be.

What does an agentic RAG architecture look like?

An agentic RAG architecture wraps the fixed pipeline in a controller that can loop. The usual parts are a query rewriter, a retriever the agent can call more than once, a grader that scores whether the chunks are relevant, and a step that decides to answer, search again, or decline. The retrieval and grounding underneath are the same ones I cover in RAG architecture.

Corrective RAG is a clear example: it grades the retrieved documents and, when they are weak, rewrites the query and runs a fresh search before answering. To wire steps like these into a loop the model drives, LangGraph models the whole thing as a graph of nodes and edges, which keeps a multi-step agent readable rather than a tangle of callbacks.

How do you evaluate and cap an agentic loop?

You evaluate it the way you evaluate any RAG system, plus the loop itself. Score retrieval and the answer separately, as in RAG evaluation, then add two measures the agent creates: how many retrieval rounds each question took, and how often those extra rounds actually changed the final answer. If a second round rarely moves the result, you are paying for nothing.

Then cap it so it cannot run away. Put a hard limit on the number of rounds, a limit on total tokens, and a fixed reply for when the agent still has nothing, the same decline a plain pipeline gives. Self-RAG helps here, because the model emits its own retrieve-or-not and support judgements, and the agentic RAG survey collects the benchmarks people score these systems on. Log every round, its query and its scores, which is what LLM observability exists for.

When should you bring in help?

If you are weighing a plain pipeline against an agentic one, or an agentic loop you built is slow and no more accurate than a single search, that is the kind of thing I sort out. The extra rounds are real money: each one runs the model again on a longer prompt, and at $2 per million input tokens for a mid-tier model in 2026, a chatty loop shows up on the bill.

I build retrieval over your own content, prove where a loop earns its cost and where it does not, and keep the answers measurable either way. You can see the shape of it on RAG development. If a fixed pipeline is all you need, I will say so.

From the work

  • AI reply grounded in cited help-centre content, shadow-mode draft metrics per channel, and metered AI credits in billing.

    Evoriqa

    My own SaaS: a multi-tenant AI customer-support platform, live in production, built by the person who also pays its inference bill.

    Live in production

    • Next.js
    • TypeScript
    • PostgreSQL
  • PDF chat with document scope selector, landing page and upload queue of a RAG assistant that cites its pages.

    AI PDF Chat

    Upload several PDFs and ask questions across all of them or one; every answer cites the PDF and page, and the citation opens the passage highlighted.

    • Next.js
    • Express
    • LangChain

The offer this article leads to: RAG development, typically $4k-$10k.

Tell me what you’re building and where it’s stuck.

I’ll tell you the cleanest path forward, including if it’s “don’t build that.”

Email only, on purpose: it reaches me, not a sales team.

Or write tocontact@alihassan.dev

Ali Hassan in a dark winter jacket, looking off to one side, standing in a stone courtyard with a minaret and cloudy sky behind him.