Reference

What Is Agentic RAG?

Standard RAG retrieves once and hopes the chunks were right. Agentic RAG lets the model check its own retrieval and go back for more, which fixes the questions RAG fails on and multiplies what an answer costs.

Updated 27 July 2026

In short
Agentic RAG is retrieval-augmented generation with an AI agent in control of the retrieval loop. Instead of one fixed retrieve-then-generate pass, an agent decides what to search, which sources or tools to use, whether the results are good enough, and when to retrieve again. It handles multi-hop questions and fragmented knowledge bases that break traditional RAG, at the cost of more model calls per answer.
Comparison

Traditional RAG vs agentic RAG

Classic RAG is a straight line. A query comes in, an embedding model turns it into a vector, the vector store returns the nearest k chunks, and those chunks go into the prompt. One retrieval, one generation, done in under a second. The design assumes the first search was good enough, and for a support bot answering “how do I reset my password” it usually is.

Agentic RAG breaks the line into a loop with a decision at every turn. The agent can rewrite a badly phrased question, run two searches against different stores, notice that the results contradict each other, and go back for a third. Retrieval stops being a fixed step and becomes a tool the model chooses to call.

Traditional RAGAgentic RAG
Control flowFixed pipelineLoop with branching
Retrievals per queryOneOne to many, decided at run time
Query handlingUsed as writtenRewritten, decomposed, filtered
SourcesUsually one indexSeveral indexes, APIs, SQL, tools
Quality controlNone after retrievalGrading step can force a retry
Model calls13 to 10 typical
LatencyUnder a secondSeveral seconds
Failure modeConfident answer from wrong chunksLoop that will not converge
The last row is the one teams underestimate. Agentic systems fail by spending, not by staying silent.
Architecture

Agentic RAG architecture

Four components show up in almost every implementation. A router reads the question and decides what to do next. Retriever tools are the things it can call: a vector index, a keyword index, a SQL query, a live API. A grader scores whatever came back against the question and returns a verdict. A generator writes the final answer once the grader is satisfied.

Only the loop is new. The retrieval machinery underneath is the same embedding model and vector store you would use for ordinary RAG, which is why teams can add the agentic layer on top of an existing pipeline rather than rebuilding it.

# The loop is the whole idea. Everything else is a tool.
context, attempts = [], 0

while attempts < MAX_ATTEMPTS:
    plan = router(question, context)          # cheap model
    if plan.action == "answer":
        break
    context += TOOLS[plan.tool](plan.args)    # no model call
    verdict = grader(question, context)       # cheap model
    if verdict.sufficient:
        break
    question = verdict.rewritten_query        # cheap model
    attempts += 1

answer = generator(question, context)         # frontier model

Here is a real trace through that loop. The question needs two sources and cannot be answered by a single similarity search, because “open compliance finding” never appears verbatim in the wiki:

query: "Which suppliers in the Q3 audit had both a late delivery
        and an open compliance finding?"

01  router          plan: two sources needed (ERP + audit wiki)
02  retrieve.sql    late_days > 0 AND quarter = 'Q3'      -> 41 rows
03  retrieve.vector "open compliance finding"     k=12    -> 12 chunks
04  grade           6 of 12 chunks off-topic, no overlap
                    with supplier ids from step 02        -> RETRY
05  rewrite         "unresolved finding OR remediation pending"
                    + filter: supplier_id IN (41 ids)
06  retrieve.vector rewritten query               k=12    -> 11 chunks
07  grade           9 chunks map to 7 suppliers           -> PROCEED
08  generate        answer + 7 citations

model calls: 5      tokens: 38,400 in / 2,100 out      wall clock: 6.8s

Step 04 is the part that distinguishes the pattern. A standard pipeline would have handed those twelve chunks straight to the model, and half of them were about suppliers not in the audit at all. The grader caught the mismatch, the rewrite added a filter derived from step 02, and the second search returned chunks that actually intersect the SQL result.

Single-agent designs put all of this behaviour in one loop, as above. Multi-agent designs give each corpus its own retrieval specialist and add a supervisor that delegates and merges. Multi-agent is easier to reason about when sources have genuinely different query languages. It also doubles the number of model calls and makes traces much harder to read, so start with one agent.

Fit

When you actually need it

Agentic RAG earns its cost in four situations:

  • Multi-hop questions. The answer requires a fact retrieved in step one to construct the search in step two. No single embedding of the original question can find both halves.
  • Several corpora with different shapes. Contracts in a document store, usage in a warehouse, tickets in a helpdesk. Choosing where to look is itself a reasoning step.
  • Vocabulary mismatch. Users ask in business language, documents are written in internal jargon. A rewrite step recovers what a raw similarity search misses.
  • Answers that must be current. When part of the answer lives behind a live API rather than in an index, retrieval has to include a tool call.

Most deployed RAG systems have none of these properties. A product FAQ bot, a policy lookup over one handbook, a docs search over a single site: these are single-hop questions against one corpus, and adding a loop makes them slower, pricier, and harder to evaluate without making them more accurate. Measure your standard pipeline first. If retrieval recall is already above ninety percent on your golden set, the agent has nothing to fix.

The honest test is whether your failing queries fail because retrieval found the wrong thing, or because there was nothing right to find. Only the first kind is worth a loop.
Economics

What agentic RAG costs to run

Take the trace above: 38,400 input tokens and 2,100 output tokens across five model calls. The equivalent single-pass RAG answer would have been roughly 6,000 input tokens and 400 output in one call. That is a six-fold increase in tokens and a five-fold increase in requests, for one question.

The saving lever is that those five calls are not equally demanding. Routing, grading, and query rewriting are short, structured, and heavily constrained. They are classification problems dressed as generation. Only the final answer needs a frontier model, and it consumes a fraction of the total input volume.

StepShare of input tokensModel class needed
RouterLowSmall, fast
Grader (per iteration)HighSmall, fast
Query rewriteLowSmall, fast
Final generationModerateFrontier
Grading dominates token volume because every retrieved chunk passes through it, which is exactly why sending grading to a frontier model is the most common way teams overspend on agentic RAG.

Route every step to the same frontier model and an agentic answer can cost five to ten times a single-pass answer. Route the loop steps to a small model and keep the frontier model for generation, and the gap narrows sharply, because the expensive model now sees one prompt instead of five. The arithmetic depends on your own chunk sizes and iteration counts, which you can work through in the token cost calculator, and the cost of RAG covers the indexing side.

Two other controls matter at volume. Cap the loop; an agent that has failed grading three times will usually fail a fourth, and a hard limit turns an unbounded bill into a bounded one. And cache the system prompt and tool definitions, which repeat identically on every iteration.

Build

Implementing agentic RAG

Build order that tends to work: get a plain RAG pipeline correct first, write a golden set of fifty real questions with known-good answers, then add one loop step at a time and measure. Grading first, because it tells you whether the loop is needed. Query rewriting second. Multi-source routing last, since it is the step that most often introduces regressions.

LangChain, LlamaIndex, LangGraph, and DSPy all give you the loop scaffolding. None of them give you the operational layer, and that is where agentic RAG projects actually stall: you need per-step model selection, a fallback when a provider is down, traces that show which iteration produced the bad citation, and cost attribution fine-grained enough to tell grading spend from generation spend.

That layer is what Swfte Connect is: one API across 50+ providers, so the router can call a small model and the generator a frontier one without two SDKs, with automatic failover and per-call cost telemetry. Studio sits above it for teams who would rather assemble the loop visually and run evals against a golden set than maintain the orchestration code. Neither replaces your vector store or your framework choice.

Adjacent patterns

Agentic RAG vs MCP and other context patterns

These get compared because both put external information in front of a model, but they solve different halves of the problem. Agentic RAG is a retrieval strategy: how the model decides what to look for and whether it found it. The Model Context Protocol is a connection standard: how a tool advertises itself to any model client so you stop writing a bespoke integration per tool. An MCP server exposing vector search is a perfectly ordinary component inside an agentic RAG loop. RAG vs MCP works through the distinction in detail.

Long-context prompting is the other alternative, and it is a real one. If your corpus fits in a context window and you can afford to send it every time, skip retrieval entirely. Fine-tuning is not an alternative; it changes behaviour and style, not the facts a model has access to, and it cannot cite a source. Retrieval and fine-tuning answer different questions, and teams that substitute one for the other usually end up doing both.

Common questions

What is the difference between RAG and agentic RAG?
Traditional RAG runs a fixed pipeline: embed the query, retrieve top-k chunks, generate an answer. Agentic RAG puts an agent in charge of that pipeline: it can rewrite the query, choose between sources, judge whether retrieved context is sufficient, and loop until it is. RAG is a pipeline; agentic RAG is a decision-maker operating one.
Is agentic RAG more expensive than normal RAG?
Yes, per query. Every reasoning step, retrieval decision, and self-check is an additional model call, so an agentic answer can cost several times a single-pass answer. Teams control this by routing lightweight steps to cheaper models and only using frontier models for final generation.
When should I use agentic RAG instead of standard RAG?
Use it when questions are multi-hop, span multiple knowledge sources, or require deciding between tools, for example combining a document store with a live API. If your queries are single-topic lookups against one corpus, standard RAG is cheaper and easier to evaluate.
What does an agentic RAG architecture look like?
A typical setup has a routing agent that interprets the query, one or more retriever tools (vector search, keyword search, APIs), a grading step that scores retrieved context, and a generation step that produces the answer, with the agent allowed to loop back when grading fails.
Do I need a specific framework for agentic RAG?
No. LangChain, LlamaIndex, and similar frameworks provide agent loops, but agentic RAG is a pattern, not a product. What matters operationally is model access, per-step routing, observability, and evals, which is the layer an LLM gateway like Swfte Connect provides regardless of framework.