Book a free call

How to Design an Agentic RAG Architecture

An agentic RAG architecture lets an AI agent plan, search and check its own work. Here is how to design each layer so the loop stays accurate and affordable.

Hertiv engineering teamReviewed by a senior engineer
7 min read
How to Design an Agentic RAG Architecture
On this page

Short answer

An agentic RAG architecture is the design of a system where an AI agent plans its own searches instead of running one fixed retrieval step: a planner breaks the question into steps, a retriever fetches passages for each step, narrow tools do the work, and memory keeps the findings. Guardrails check citations before the answer leaves, so the loop can fix its own weak searches within clear limits.

What is an agentic RAG architecture?

An agentic RAG architecture is the design of a system where an AI agent plans, searches and checks its own work instead of running one fixed retrieval step. The agent decides what to look up, which tools to call, when to search again and when the answer is good enough to give.

Standard RAG follows a set path: take the question, fetch passages, write the answer. Agentic RAG adds a loop around that path, so the agent can break a hard question into parts, search for each part, compare what comes back and try again when the first search misses. The architecture is the set of layers that makes that loop reliable.

LayerJob
PlannerBreaks the question into steps and picks the next action
RetrieverFinds passages from the knowledge base for each step
ToolsRuns narrow actions such as search, lookup and calculation
MemoryKeeps the plan, the findings and the open questions
GuardrailsChecks sources, citations and limits before answering

Each layer can fail on its own, so the design is judged by what happens when one does. A good architecture keeps working when a search returns nothing useful, a tool fails, or the plan turns out wrong, and it leaves a trace of every step so the team can see why an answer came out the way it did.

How does the planner layer work?

The planner layer works by turning a user question into a short list of steps, then choosing the next step based on what the last step found. It is the part of the system that decides, not the part that fetches or writes.

A simple plan has two or three steps: find the policy, find the price, then combine them. A harder question needs a plan that branches: if the first search returns nothing, try a different wording; if two sources disagree, fetch a third. The planner keeps the goal in view while the steps change underneath it.

Keep plans short and explicit. Write the plan down in the trace, with one line per step, so a reviewer can see what the agent intended before it acted. Limit the number of steps and the number of searches per question, so a bad plan cannot run forever. The agentic RAG walkthrough shows the loop in action.

How does the retrieval layer work?

The retrieval layer works by turning each planned step into a search, then returning the passages the agent needs for that step and nothing more. It is the same job as standard RAG, but it runs several times per question instead of once.

Each step gets its own query, written from what the planner knows so far. The retriever combines keyword and vector search, re-ranks the results, and drops passages that do not match the step. That keeps the context small and focused, which matters because a long, noisy context makes the agent worse, not better.

Retrieval choiceWhat it does
Query rewritingTurns each step into a search the index can answer
Hybrid searchCombines keyword match with vector similarity
Re-rankingOrders passages by fit to the current step
Freshness filterDrops old passages when dates matter

Record which passages were used for each step, so a citation can point back to the exact source. When retrieval returns nothing useful, the planner should see that as a signal to rephrase or to stop and say so, not as a reason to guess.

How do tools and memory fit in?

Tools and memory fit into an agentic RAG architecture as the agent's hands and its notebook. Tools do the work the model cannot do on its own, and memory keeps the plan, the findings and the open questions so the agent does not repeat itself or lose track.

Keep each tool narrow: one search tool, one lookup tool, one calculator, each with clear inputs and a clear result. The planner picks tools by name and purpose, never by guessing what a tool might do. A tool registry that lists each tool, its inputs and its limits is the part of the architecture that keeps tool use safe.

Memory has two parts. Short-term memory holds the current question, the plan and what has been found so far. Long-term memory holds facts the agent may reuse, such as user preferences or past decisions, and it needs rules about what is stored, how long it lasts and who can see it. Without those rules, memory becomes a leak.

How do guardrails and evaluation fit in?

Guardrails and evaluation fit into an agentic RAG architecture as the checks that run before an answer leaves the system and the tests that run after. Guardrails catch bad answers in real time, and evaluation catches patterns the guardrails miss.

Guardrails check four things: every factual claim has a citation, the citation actually supports the claim, the answer stays within the agent's allowed topics, and the cost and time limits for the question were respected. If a check fails, the agent should retry once with a narrower plan, then hand off or say it does not know.

Evaluation needs its own test set of questions with known answers, including questions that should fail. Run the set weekly, and track how often the agent answers, how often its citations hold up, and how often it stops instead of guessing. The agentic RAG best practices guide covers the operating rules that sit on top of this design.

How do you design an agentic RAG architecture in 6 steps?

You design an agentic RAG architecture by starting with the RAG base, then adding the agentic loop one layer at a time, with a test set that grows as the design does. The steps below fit a normal development cycle.

  1. Build the RAG base first. Chunk the documents, build the index and get one-pass retrieval working well.
  2. Add the planner. Let the agent break questions into steps, with a step limit and a written plan trace.
  3. Add narrow tools. Register each tool with its inputs and limits, and keep write tools behind approval.
  4. Add memory with rules. Short-term memory for the current question, long-term memory with storage and access rules.
  5. Add guardrails and logging. Citation checks, cost and time limits, and a trace of every step.
  6. Test with failures, then launch small. Kill a source, break a tool and ask an unanswerable question on a test set, then open to a few users.

Raise the limits only after the system has run cleanly for a few weeks. The RAG architecture guide covers the base system this design builds on.

Example (hypothetical): a support agent that searches twice

Example (hypothetical): a support team gets 600 questions a week about a product with a large manual. A one-pass RAG system answers 420 of them correctly, which is 70 in 100, and the rest get a wrong or incomplete answer. The team adds an agentic loop that lets the agent search a second time when the first search looks weak.

Of the 180 questions the first pass misses, the agent retries 150 with a rewritten query. The second search fixes 90 of them, so the total correct rises from 420 to 510, which is 85 in 100. The remaining 90 questions go to a person, because the agent stops instead of guessing.

The team counts the cost: the second search adds about 1 second and a small fee to 150 questions a week, which is far cheaper than the staff time the 90 fixed answers save. The retry rule stays because the numbers hold: 510 of 600 correct, 90 handed off, none invented.

What are the common mistakes?

The most common agentic RAG architecture mistakes are letting the planner run without limits, giving the agent tools it does not need, and skipping the citation checks that make the answers trustworthy. Each one is avoidable with a step limit, a narrow tool registry and a guardrail that runs before every answer.

  • No step or cost limit. A planner without limits can loop for minutes and run up a large bill on one question.
  • Tools that are too broad. A tool that can do anything is a tool the agent will misuse. Keep each tool narrow and named.
  • Memory without rules. Stored facts with no expiry or access rules become stale answers and leaks.
  • No citation check. An answer without a checked citation is a guess, however fluent it sounds.
  • Testing only the happy path. Unanswerable questions and broken tools are where the design is really tested.
  • No trace of the steps. Without a plan trace, the team cannot see why an answer went wrong.

Design the failure paths first, then the happy path. The agentic RAG explainer covers the basics this design builds on.

Key takeaways

  • An agentic RAG system has five layers: planner, retriever, tools, memory and guardrails
  • Keep plans short and written down, with a step limit and a cost limit per question
  • Give each planned step its own rewritten query, and re-rank before the agent reads the passages
  • Keep tools narrow and registered, and give memory clear storage and access rules
  • Check every citation before the answer leaves, and test with unanswerable questions

Frequently asked questions

What is agentic RAG architecture?

It is the design of a retrieval system where an AI agent plans its own searches: a planner breaks the question into steps, a retriever fetches passages for each step, tools do the work, memory keeps the findings, and guardrails check the answer before it leaves.

How is agentic RAG different from standard RAG?

Standard RAG follows one fixed path: fetch passages once, then write the answer. Agentic RAG adds a loop, so the agent can break a hard question into parts, search again when the first search misses, and stop when the answer is good enough.

What does the planner do in agentic RAG?

It turns the question into a short list of steps and picks the next step based on what the last step found. It keeps the goal in view while the steps change, and it records the plan so a reviewer can see what the agent intended.

Why does agentic RAG need memory?

Memory keeps the plan, the findings and the open questions so the agent does not repeat searches or lose track. Short-term memory holds the current question; long-term memory holds reusable facts, with rules about what is stored and who can see it.

How do you stop an agentic RAG loop from running forever?

Set a step limit and a cost limit per question, and make the planner stop when the answer is good enough or when a search returns nothing useful twice. A retry should rephrase the query, not repeat it.

Should a small team build agentic RAG from scratch?

Usually not. Start with a working one-pass RAG system, then add the planner and the guardrails on top of it. Most small teams use an existing agent framework for the loop and design their own tools, memory rules and evaluation around it.

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

Designing an agentic RAG system? 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 contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call