Book a free call

How Does Agentic RAG Work? A Practical Walkthrough

Agentic RAG hands the retrieval loop to an AI agent: it plans searches, checks the results, and searches again until the answer is grounded. Here is how it works.

Hertiv engineering teamReviewed by a senior engineer
7 min read
How Does Agentic RAG Work? A Practical Walkthrough
On this page

Short answer

Agentic RAG is a retrieval system in which an AI agent plans and runs the searches itself instead of following a fixed pipeline. The agent splits a question into smaller searches, reads the retrieved chunks, judges whether they answer the question, and searches again when the evidence is thin, then drafts an answer with citations to the chunks it used.

What is agentic RAG?

Agentic RAG is a retrieval-augmented generation system in which an AI agent controls the retrieval loop instead of following a fixed pipeline. The agent decides what to search for, reads the results, judges whether they answer the question, and searches again when the evidence is thin. That loop is what makes it agentic: the system plans its own work rather than running the same steps for every question.

A standard RAG pipeline runs once: embed the question, fetch the top chunks, and hand them to the model. That works when the first search returns the right passages. Agentic RAG adds a decision-maker between the steps, so the system can split a hard question into smaller searches, try different phrasings, or call a calculator, a database or an API when the documents do not hold the answer.

The agent is usually a large language model with a set of tools and a short instruction that tells it when to search, when to stop, and how to show its sources. Every step it takes is logged, so a team can see which searches ran and why the agent trusted the chunks it cited. That log is what makes the system debuggable, which matters once it answers real users.

How is agentic RAG different from standard RAG?

Standard RAG and agentic RAG share the same building blocks: a document store, an embedding model and a language model. They differ in who controls the flow. In standard RAG the flow is fixed at design time. In agentic RAG the agent chooses the flow at run time, based on what it finds.

Aspect Standard RAG Agentic RAG
Who plans the search The designer, at build time The agent, at run time
Number of searches One per question One or more, until the answer is covered
Tool use Usually none Search, reranking, APIs, code, memory
Missing answers Answered from weak chunks or guessed Agent tries new searches or says it cannot answer
Debugging Simple: one search to inspect Needs logs of every step the agent took
Best fit Questions with one clear answer in the docs Multi-part questions that need digging

The extra freedom comes with extra cost. Each extra search adds tokens and time, and an agent that loops too long can burn through a budget on one question. That is why agentic RAG suits questions that need digging, while a fixed pipeline suits questions with one clear answer in the docs.

How does the agentic RAG loop work?

The loop has five stages, and the agent can repeat the middle three until it is satisfied or hits a limit. The loop is the core of the system, so it is worth tracing once in detail.

  1. Plan. Break the question into sub-questions and pick the first search.
  2. Retrieve. Search the vector store and return the top chunks.
  3. Judge. Check whether the chunks answer the sub-question.
  4. Act. Search again with new terms, call a tool, or move on to the next sub-question.
  5. Answer. Draft the reply with citations to the chunks that were used.

Two limits keep the loop honest: a maximum number of rounds, often three to five, and a rule that the agent must cite the chunks it used. Without the round limit, a hard question can loop for a long time. Without citations, there is no way to check whether the answer came from your data or from the model's memory.

Most teams start with a round limit of three. That is enough for the agent to try a second phrasing and one follow-up search, while keeping the cost per question in a range the team can predict.

What tools does an agentic RAG system use?

An agentic RAG system is a small toolbox around the agent. The tools are simple on their own; the value is in how the agent combines them. Most production systems use four or five of these, not all of them at once.

  • Vector search. Finds passages by meaning, not by exact words.
  • Keyword search. Finds exact terms, codes, order numbers and names.
  • Reranker. Reads the retrieved chunks and keeps only the ones that match the question.
  • Web or API search. Fills gaps that the internal documents cannot cover.
  • Memory. Stores what the agent already learned in this session, so it does not search twice for the same fact.
  • Calculator or code runner. Checks numbers instead of guessing them.

The retriever and the reranker do most of the work. A good reranker can turn a weak first search into a useful answer, because it reads the chunks and keeps only the ones that match the question. Teams that skip the reranker often blame the model for answers that were caused by poor retrieval.

Tool choice should follow logged failures. If the agent keeps missing order numbers, add keyword search. If it keeps quoting the wrong document, add a reranker. Each tool should answer a failure you have already seen, not one you imagine.

Example (hypothetical): a support agent that searches twice

Example (hypothetical): a support team holds 12,000 help articles. A customer asks why a refund for order 4417 has not arrived after 10 days. The agent first searches for the refund policy and finds that refunds take 5 to 10 working days. That does not settle the question, so it searches again for order 4417 in the order system and finds the refund was sent on day 9.

The numbers show why the second search matters. The first search returns 5 chunks, none of which mention order 4417. The second search returns 3 chunks, and 1 of them holds the refund record.

The agent then answers with both facts: the policy allows 10 working days, and this refund was sent on day 9, so it should land within 1 working day.

Two searches, 8 chunks read, 2 cited, and the customer gets a dated answer instead of a generic policy quote.

A fixed pipeline would have stopped after the first search and quoted the policy. The agent earned its keep by noticing the gap and filling it with a second, targeted search. That is the whole case for agentic RAG in one exchange: the first search found the rule, the second found the fact.

What are the common mistakes?

The most common agentic RAG mistakes are giving the agent too many tools, letting it loop without a limit, and skipping the evaluation step that shows whether the extra searches actually help.

  • Too many tools. Each extra tool is another way for the agent to go wrong. Start with search and a reranker.
  • No round limit. A hard question can run ten searches and still miss. Cap the loop at three to five rounds.
  • No citations. Answers that cannot be traced cannot be trusted. Require the agent to cite every chunk it uses.
  • Weak retrieval. The agent cannot fix chunks that were never indexed well. Clean the documents before adding an agent.
  • No fallback. When the docs have no answer, the agent should say so instead of guessing.

How to start with agentic RAG

You start with agentic RAG by adding an agent to a working RAG pipeline, not by building an agent first. The pipeline gives you a baseline to beat, and the agent gives you a way to beat it on the hard questions.

  1. Ship a fixed RAG pipeline and log the questions it gets wrong. The log is your test set.
  2. Pick the 20 questions where a second search would have helped. These are the cases the agent must win.
  3. Give the agent a search tool, a reranker and a round limit of three. Keep the toolset small at first.
  4. Test on those 20 questions and compare the answers with the baseline. Keep the agent only if it wins clearly.
  5. Add tools one at a time, only when a logged failure shows the need. Each tool should fix a failure you have seen.

If you are building the system for production, a partner for RAG development can help set up the pipeline, the agent loop and the evaluation set together, so the agent is tested against real questions from the start.

Key takeaways

  • Agentic RAG hands the retrieval loop to an agent that plans, searches, judges and searches again
  • Standard RAG runs one fixed search; agentic RAG runs as many as the question needs, up to a round limit
  • The reranker and the citations are what keep the agent honest and its answers checkable
  • Cost grows with every extra search, so the agent should earn its place on hard questions only
  • Start from a working fixed pipeline, test the agent on logged failures, and add tools one at a time

Frequently asked questions

When should I use agentic RAG instead of standard RAG?

Use agentic RAG when a question needs more than one search: multi-part questions, questions that mix documents with live data, and questions where the first search often misses. Use standard RAG when the answer sits in one passage and the question is asked the same way every time.

How many searches does an agentic RAG system run per question?

Most systems cap the loop at three to five rounds. Simple questions finish in one round, and hard ones use two or three. The cap matters because each round adds tokens and waiting time, and an agent without a cap can loop on a question it cannot answer.

Does agentic RAG cost more than standard RAG?

Yes, usually. Every extra search and every extra model call adds tokens, and the agent itself needs a model call to plan each round. Teams accept the cost on hard questions and keep the fixed pipeline for the simple ones, so the average cost stays in range.

Can agentic RAG use tools other than search?

Yes. Common tools include a reranker, keyword search, a web search, an API call to a live system, a calculator and short-term memory. The agent picks the tool that fits the gap it found. Most teams start with search and a reranker and add tools only when a logged failure shows the need.

How do I know if my agentic RAG answers are correct?

Require citations to the chunks the agent used, log every search the agent ran, and test on a fixed set of real questions with known answers. If the citations do not support the answer, the answer is wrong even when it reads well.

What is the difference between agentic RAG and an AI agent?

An AI agent is the general pattern: a model that plans steps and uses tools to reach a goal. Agentic RAG is one use of that pattern, where the goal is answering a question from your own documents. The agent is the worker; RAG is the job it is doing.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning an agentic RAG system for your own data? Talk to Hertiv.

A senior engineer replies within one business day. Or see our RAG Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call