
Running Agentic RAG in Production: What Actually Works
Running agentic RAG in production is where backend and ML engineers learn the hard truth: the demo worked until the agent forgot what it retrieved three turns ago. It retrieved correctly. Then it burned budget re-fetching the same facts, or stitched a stale answer from a context it no longer held. That's not a model problem. It's a memory and orchestration problem, and it's the first thing that breaks under real traffic, real users, and real budgets.
Most guides soft-pedal this. They show you the happy path and skip the failure cases. This one doesn't. You'll get the honest architecture, the memory patterns that actually hold up, and the scenarios where you should not build agentic RAG at all. GigaRAG is one tool built for agent memory and pipeline builders like you, but the guidance here stays vendor-neutral.
| At a glance | Details |
|---|---|
| Core challenge | Agent forgets retrieved context across turns |
| Memory split | Short-term (session) vs long-term (persistent) |
| Failure trigger | Multi-hop queries with stale or missing memory |
| Eval focus | Retrieval recall, answer faithfulness, task success |
| Cost driver | Token usage from repeated retrieval and reasoning loops |
| Readiness gate | Scorecard before production traffic |
In This Guide
- What Is Agentic RAG?
- Agentic RAG vs Classic RAG: When to Use Which
- Core Components of a Production Agentic RAG System
- Running Agentic Rag In Production: A Step-by-Step Guide
- Agent Memory: The Missing Piece in Most Production RAG Systems
- How to Make an Agentic RAG System
- Evaluating Agentic RAG in Production
- When Running Agentic RAG in Production Is a Bad Idea
- Multi-Agent Coordination Patterns
- Cost Optimization for Agentic RAG
- Production Readiness Scorecard for Agentic RAG
- Is RAG Still Relevant in an Agentic World?
- Final Thoughts on Running Agentic RAG in Production
What Is Agentic RAG?
Agentic RAG is retrieval-augmented generation where an LLM agent controls the retrieval process itself, deciding when to search, what to search for, and whether the results are good enough, instead of following a fixed retrieve-then-generate pipeline.
Vanilla RAG runs one retrieval pass, stuffs the results into the prompt, and generates an answer. Agentic RAG lets the model loop: retrieve, evaluate, decide it needs more or different context, and retrieve again.
Agentic RAG vs vanilla RAG
The difference is control flow. Vanilla RAG is linear: query in, top-k chunks out, answer generated. The model never questions the retrieval. If the chunks are wrong or incomplete, the answer is wrong.
Agentic RAG gives the model tools: a search function, a reranker, maybe a database lookup. The agent decides when to call them. It can reformulate a query that returned nothing useful. It can retrieve from two sources and compare. It can stop after one pass when the answer is obvious.
That flexibility costs latency and tokens. You're trading a single retrieval call for a loop that might run three or five times.
The decision-retrieve-evaluate-refine loop
Here's what happens behind the scenes. The agent receives a query and decides whether it needs external context at all. If yes, it picks a retrieval tool and formulates a search. It evaluates the results: are they relevant, complete, current? If not, it refines the query or switches tools and retrieves again. It repeats until the context is sufficient or it hits a step limit.
The loop is where production complexity lives. Every iteration burns tokens and adds latency. The agent can loop too long, retrieve the same facts twice, or chase a tangent. Guardrails on step count and a clear stopping condition are not optional.
[!note] Agentic RAG is not a drop-in replacement for classic RAG; it adds planning and memory layers that change latency, cost, and failure modes. Treat it as a new system with its own observability and evaluation needs.
Agentic RAG vs Classic RAG: When to Use Which
| Factor | Agentic RAG | Classic RAG |
|---|---|---|
| Query complexity | Multi-hop, ambiguous, or tool-using | Single-hop, well-scoped lookups |
| Latency profile | Higher due to planning and loops | Lower, single retrieval pass |
| Memory needs | Short-term and long-term memory required | Stateless per query |
| Failure modes | Memory loss, runaway loops, cost spikes | Retrieval miss, context overflow |
| Best fit | Research assistants, complex workflows | FAQ bots, document Q&A |
Core Components of a Production Agentic RAG System
A production agentic RAG system has five moving parts. Skip any one and you'll find out in production, usually at 2 a.m.
Retrieval layer
This is the substrate. You need a vector store, an embedding model, and a reranker. The vector store holds your chunks. The embedding model turns queries and chunks into vectors. The reranker scores the top candidates and drops the weak ones before they reach the agent.
The agent doesn't replace this layer. It sits on top of it. If retrieval returns garbage, the agent burns tokens trying to fix it. Get vanilla RAG solid first.
Agent reasoning loop
The loop is where the agent decides what to do next. It receives a query, picks a tool, evaluates the result, and decides whether to continue or stop. Every decision is an LLM call. Every call costs tokens and adds latency.
You need a step limit. Without one, the agent can loop indefinitely on a hard query. You also need a stopping condition: the agent must know when the context is good enough.
Tool-calling interface
Tools are functions the agent can invoke: search, database lookup, calculator, API call. Each tool needs a clear description so the model knows when to use it. Vague tool descriptions cause wrong tool selection.
Keep the tool count small. Three well-described tools beat ten poorly-described ones. The agent will call the wrong tool if the descriptions overlap.
Memory layer
Memory is what separates a demo from a production system. Short-term memory holds the current conversation: what was retrieved, what was asked, what was answered. Long-term memory holds facts, preferences, and failed retrievals across sessions.
Without memory, the agent re-retrieves the same facts every turn. That's wasted tokens and slower responses.
Guardrails and validation
Guardrails catch what the agent gets wrong. Citation validation checks that generated claims trace back to retrieved chunks. Step limits stop runaway loops. Output filters block disallowed content.
You also need observability: logs of every retrieval, every tool call, every decision. When the agent gives a wrong answer, you need the trace to see why.
[!tip] For backend and ML engineers: start by logging every retrieval and agent decision in a structured format (e.g., JSON with timestamps, query, retrieved doc IDs, and token counts). This trace becomes your debugging goldmine when the agent forgets context three turns later.
Running Agentic Rag In Production: A Step-by-Step Guide
- Define the agent's task boundaries and success criteria before writing code.
- Implement short-term memory with a sliding window or summarization to avoid context overflow.
- Add long-term memory with a vector store for facts, user preferences, and past interactions.
- Instrument retrieval and generation with tracing to capture recall, latency, and token usage.
- Build an evaluation set of real user queries and measure task success, not just answer quality.
- Set cost and latency budgets, and add circuit breakers for runaway agent loops.
- Run a staged rollout with shadow traffic and a rollback plan before full production.

Agent Memory: The Missing Piece in Most Production RAG Systems
The previous section named memory as one of five components. Most writeups stop there. They list "memory" and move on. That's the gap. Memory is where production agentic RAG actually breaks, and it breaks in ways that don't show up in a notebook.
Short-term vs long-term agent memory
Short-term memory is the working context of the current session. It holds the conversation turns, the chunks retrieved so far, and the intermediate reasoning steps. It lives in the context window or a scratchpad. It dies when the session ends.
Long-term memory persists across sessions. It holds facts the agent has learned, user preferences, and records of what didn't work. It lives in a database, not the context window.
The distinction matters because they fail differently. Short-term memory fails by overflowing: too many turns, too many retrieved chunks, and the agent starts dropping earlier context. Long-term memory fails by poisoning: stale facts, contradictory preferences, and irrelevant entries get injected into retrieval and corrupt the answer.
What to store: facts, preferences, and failed retrievals
Three things belong in long-term memory. Facts are things the agent verified and will need again: a customer's account tier, a product's release date, a policy that changed. Preferences are how the user wants answers: format, depth, tone. Failed retrievals are the most underrated category. When a query returns nothing useful, store that. Next time the agent sees a similar query, it can skip the doomed retrieval and try a different strategy.
Don't store everything. Storing raw conversation transcripts as memory is a fast way to bloat your store and poison retrieval. Store distilled facts, not transcripts.
Memory decay and eviction strategies
Memory rots. Facts go stale. Preferences change. You need a decay policy.
The simplest approach is timestamped entries with a TTL. Facts older than 90 days get re-verified or dropped. Preferences get refreshed on every session. Failed retrievals get a short TTL because the underlying index may have changed.
Eviction is the harder problem. When memory is full, what do you drop? Least-recently-used is a reasonable default. But for facts, recency isn't the right signal. A customer's account tier from last week matters more than a formatting preference from yesterday. Weight by importance, not just recency.
How GigaRAG approaches agent memory
GigaRAG treats memory as a first-class retrieval target, not an afterthought. Short-term context and long-term facts live in separate stores with separate retrieval paths. That means the agent can query memory without polluting the document retrieval index.
The main catch: GigaRAG's memory features assume you're already running its retrieval stack. If you've built your own vector store and reranker, you'll be wiring memory in yourself. That's fine. The patterns above work with any stack.
How to Make an Agentic RAG System
Build in four steps. Skip ahead and you'll debug an agent that retrieves fine but reasons badly.
Step 1: Solidify vanilla RAG first
Get retrieval working before you add any agency. That means a vector store, an embedding model, and a reranker that returns the right chunk in the top three for your test queries. If vanilla RAG can't answer single-hop questions reliably, an agent loop won't fix it. It'll just burn more tokens failing.
Step 2: Add a minimal agent loop
Wire a decision step before retrieval. The agent sees the query, decides whether to retrieve, what to retrieve, and whether the result is good enough. Keep it to one tool: search. Don't add calculators, APIs, or code execution yet. A single-tool agent is easier to trace and debug.
Step 3: Wire in memory before adding more tools
Memory changes how the agent behaves across turns. Add short-term context first: keep retrieved chunks and prior turns in the working window. Then add long-term storage for facts and failed retrievals. Do this before you add more tools, because memory affects every tool call the agent makes. Adding tools first means redoing the memory wiring later.
Step 4: Add evaluation from day one
Log every query, every retrieval, every decision. Score retrieval precision and answer correctness on a fixed test set from the first build. Without a baseline, you won't know whether the agent loop helped or hurt. Latency and cost per query go in the same log. You'll need them when you hit production traffic.
Evaluating Agentic RAG in Production
You built the thing. Now you need to know if it works. Most teams stop at RAGAS scores and call it done. That's a mistake.
Why RAGAS alone is not enough
RAGAS measures faithfulness, answer relevance, and context relevance. Useful for catching hallucination in a notebook. It tells you nothing about what happens under real traffic.
An agent that scores 0.9 on RAGAS can still take 8 seconds to answer. It can still burn $0.40 per query re-retrieving the same facts. It can still forget what the user said three turns ago. None of that shows up in a RAGAS report.
Production evaluation needs four things RAGAS doesn't cover: latency, cost per query, memory accuracy, and retrieval precision under load. Measure those or you're flying blind.
Latency and cost as first-class metrics
Latency isn't a nice-to-have. It's a budget. Set a ceiling before you ship: 2 seconds for a single-hop query, 5 seconds for a multi-step agent loop. Log every step inside the loop, not just the total. You need to know whether the retriever, the reranker, or the LLM is eating the time.
Cost per query works the same way. Track tokens per query, not just dollars. A query that costs $0.02 in the demo can hit $0.30 in production when the agent loops three times. Cache retrieval results and reuse memory to keep that number flat.
Memory accuracy evaluation
Memory is the part most teams never test. You need a test set where the correct answer depends on something the agent learned earlier in the conversation. Ask the agent a follow-up that requires recalling a fact from turn one. Score whether it gets that fact right.
Also test memory poisoning. Feed the agent a wrong fact, then ask a question where that fact would corrupt the answer. A good memory layer rejects or decays the bad fact. A bad one lets it leak into retrieval.
Online vs offline evaluation
Offline evaluation runs on a fixed test set. You control the queries, you know the answers. Do this before every deploy.
Online evaluation runs on real traffic. You don't know the answers in advance, so you sample queries and score them by hand or with an LLM judge. Sample at least 50 queries per week. Watch for drift: retrieval precision dropping, latency creeping up, memory misses increasing.
The honest answer is you need both. Offline catches regressions before they ship. Online catches what offline can't: real users asking questions you never thought to test.
When Running Agentic RAG in Production Is a Bad Idea
Agentic RAG is not a default. It's a tool for a specific job. If your queries are single-hop lookups, your latency budget is tight, or your cost per query is already painful, adding an agent loop will make things worse, not better. Here's when to skip it.
Single-hop retrieval is enough
Most production RAG systems answer questions that need exactly one retrieval. "What's the refund policy?" "What's the current price of X?" "Where's the API key?" The retriever finds the right chunk, the LLM reads it, done.
An agent loop adds nothing here. It just burns tokens deciding whether to retrieve again. If your eval shows 95% of queries resolve in one hop, you don't have an agentic problem. You have a vanilla RAG system that works. Keep it.
Latency budget is under 500ms
Agentic RAG is slow. Every loop iteration adds an LLM call, and every LLM call adds 200-800ms. A three-step agent loop can easily hit 2-3 seconds before the user sees anything.
If your product needs sub-500ms responses, agentic RAG is off the table. No amount of optimization gets you there. Use vanilla RAG with a fast retriever and a small model. The agent loop is the latency tax you can't afford.
The agent has no memory requirement
The whole point of agentic RAG is that the agent can remember context across turns, refine its retrieval strategy, and learn from failed retrievals. If your use case doesn't need that, you're paying for machinery you don't use.
A stateless Q&A bot that answers one question per session doesn't need memory. It doesn't need an agent. It needs a retriever and an LLM. Adding an agent loop to a stateless system is over-engineering, plain and simple.
Cost per query is already too high
Agentic RAG multiplies token spend. Every loop iteration re-reads the context, re-runs the retriever, and re-prompts the LLM. A query that costs $0.02 in vanilla RAG can hit $0.15-0.30 with an agent loop that iterates three times.
If your margins can't absorb that, don't build it. The honest answer is that agentic RAG is a cost multiplier, not a cost saver. It only pays off when the alternative is a wrong answer that costs you more than the tokens.
Multi-Agent Coordination Patterns
Most agentic RAG systems don't need multiple agents. One agent with a retriever, a memory layer, and a few tools handles the vast majority of production workloads. You add a second agent when the work genuinely splits along different reasoning paths, not because a diagram looks impressive.
Supervisor vs peer-to-peer patterns
A supervisor pattern puts one agent in charge. It receives the query, decides which specialist agents to call, and assembles their outputs. The specialist agents don't talk to each other. This is the production-safe default because it keeps the control flow legible. You can trace exactly which agent did what and why.
Peer-to-peer coordination lets agents call each other directly. It's more flexible, but it's also where latency explodes. Two agents negotiating back and forth can loop for ten iterations before converging, and every iteration costs tokens. I've seen peer-to-peer systems burn 4x the budget of a supervisor pattern for the same answer quality. Start with a supervisor. Move to peer-to-peer only when you have a concrete failure case the supervisor can't handle.
Shared memory across agents
Multiple agents need a shared memory layer, not separate memories per agent. If each agent keeps its own context, you get drift: one agent retrieves a fact, another agent re-retrieves the same fact because it doesn't know the first agent already found it. That's wasted tokens and added latency.
The fix is a shared scratchpad. Every agent writes its findings to the same memory store, and every agent reads from it before retrieving anything new. This turns multi-agent retrieval from N independent lookups into one coordinated search. The memory layer also needs a write policy: who can overwrite what, and when does stale data get evicted. Without that, agents overwrite each other's work and you get nondeterministic answers.
When multi-agent is overkill
If your queries resolve in one or two hops, one agent is enough. If your latency budget is under a second, multiple agents will blow it. If your team is small, debugging a multi-agent system will eat your on-call time.
The honest answer is that multi-agent coordination is a scaling pattern for complex, multi-domain queries. Most production RAG systems never hit that threshold. Build the single-agent version first, measure where it fails, and only then split the work.
Cost Optimization for Agentic RAG
Agentic RAG costs more than vanilla RAG. Every loop iteration spends tokens, and every retrieval adds latency. The levers below cut both without touching answer quality.
Caching retrieval results
Cache embeddings and retrieval results keyed by normalized query. If a user asks a variant of a question you've already answered, skip the vector search entirely. A simple in-memory LRU cache handles high-frequency queries; Redis or similar works when you need cross-instance sharing. Invalidate on document updates, not on a timer.
Query routing by complexity
Not every query needs the full agent loop. Route simple lookups straight to retrieval and a single LLM call. Send only multi-hop or ambiguous queries through the agent. A lightweight classifier (a small model or even regex rules) decides the path. This alone can cut token spend by half on head queries.
Memory reuse to avoid re-retrieval
Your agent's memory layer already stores facts from previous turns. Read from it before hitting the vector store. If the fact is in short-term memory and still fresh, use it. Re-retrieving the same document across turns is pure waste. Set a freshness window: facts older than N turns get re-verified, newer ones don't.
Model tiering for sub-tasks
Don't run your frontier model on everything. Use a small, cheap model for query classification, tool selection, and retrieval synthesis. Reserve the large model for final answer generation and complex reasoning. The cost difference is 10-50x per token, and sub-tasks rarely need the big model's capability.
Production Readiness Scorecard for Agentic RAG
Copy this checklist into your runbook. Each item is a yes/no. If you can't answer yes, you're not ready for traffic.
Memory checklist
- Short-term memory has a defined capacity and eviction policy.
- Long-term memory is stored outside the agent loop, not in the prompt.
- Failed retrievals are logged and reused to avoid repeating mistakes.
- Memory freshness windows are set per fact type, not globally.
Evaluation checklist
- You track retrieval precision separately from answer quality.
- Latency is measured at p50 and p95, not just average.
- Cost per query is logged and alertable.
- You run offline evals on a fixed dataset before every deploy.
Cost and latency checklist
- Simple queries bypass the agent loop entirely.
- Retrieval results are cached with invalidation on document updates.
- Sub-tasks run on cheaper models, not your frontier model.
- You have a per-query token budget and a kill switch when it's exceeded.
Observability checklist
- Every agent decision is traceable: which tool, which retrieval, which memory read.
- Reasoning traces are stored for postmortems, not just metrics.
- You alert on retrieval failures, not just LLM errors.
- Memory writes are logged with timestamps and sources.
Score yourself honestly. If memory and observability are the weakest boxes, fix those before adding more tools or agents.
Is RAG Still Relevant in an Agentic World?
Yes. RAG isn't replaced by agents. It's the retrieval substrate they run on.
An agent without RAG is just an LLM making things up with better formatting. The agent loop decides what to retrieve, when to retrieve it, and how to use what comes back. But the retrieval itself is still RAG: encode the query, search the index, rerank the candidates, feed the top results into context. Agents add decision-making on top of that pipeline. They don't remove it.
What changes is how RAG gets called. In vanilla RAG, you retrieve once per query. In agentic RAG, retrieval happens multiple times, often with different query formulations, as the agent refines its understanding. The retrieval layer stays the same. The orchestration around it gets more complex.
The honest answer is that RAG matters more in an agentic world, not less. Every extra retrieval step is another chance to pull in wrong context. Every memory write is another chance to poison the index. The retrieval quality floor rises because the agent multiplies the number of retrieval calls per user query. A 90% precision rate that was fine for single-hop retrieval becomes a compounding error source when the agent retrieves five times per turn.
So the question isn't whether RAG survives agents. It's whether your retrieval layer is good enough to be called repeatedly without degrading. Most aren't. That's the real gap.
Final Thoughts on Running Agentic RAG in Production
Running agentic RAG in production is a memory problem before it's a model problem. The agent loop is easy to build. Keeping the agent from forgetting what it retrieved, re-retrieving the same facts, or poisoning its own context is the hard part.
The trade-offs are honest. You gain flexibility and better answers on complex queries. You pay for it in latency, token cost, and failure modes that vanilla RAG never had. If your retrieval layer isn't solid, the agent multiplies its mistakes. If your memory layer doesn't decay, it becomes a garbage dump.
The good news is that most of this is solvable with boring engineering: caching, query routing, memory eviction, and evaluation from day one. None of it requires a frontier model. It requires discipline.
If you're building agent memory or a RAG pipeline, GigaRAG is built for exactly that. It handles the memory layer and retrieval orchestration so you don't have to hand-roll eviction policies and context management. But the scorecard in this guide applies whether you use GigaRAG or build it yourself. The checklist doesn't care about your stack. It cares whether your agent forgets things under load.
Frequently Asked Questions
Can agentic AI use RAG?
Yes. Agentic AI can use RAG as a tool or as a memory source. The agent decides when to retrieve, what to retrieve, and how to incorporate the results into its reasoning. This is often called agentic RAG.
How to make an agentic RAG?
Start with a classic RAG pipeline, then add an agent loop that can plan, call retrieval tools, and maintain memory across turns. You will need short-term memory for the current session and long-term memory for persistent facts. Instrument everything to catch failures early.
Is agentic RAG worth it?
It depends on your use case. Agentic RAG shines for complex, multi-hop queries where a single retrieval pass is insufficient. For simple lookups, classic RAG is faster, cheaper, and easier to maintain. Evaluate against your task success metrics before committing.
Is RAG still relevant?
Yes. RAG remains a foundational technique for grounding LLMs in external knowledge. Agentic RAG extends it with planning and memory, but the core retrieval and augmentation principles are still essential.
What breaks first when agentic RAG hits production?
Memory management is usually the first casualty. Agents forget retrieved context across turns, leading to contradictory or repetitive answers. Without explicit short-term and long-term memory design, even well-built demos degrade quickly under real traffic.
How do I evaluate agentic RAG in production?
Track retrieval recall, answer faithfulness, and end-to-end task success. Use a mix of offline evaluation sets and online metrics like user feedback and escalation rates. Monitor latency and token cost per query to catch regressions.
About GigaRAG
GigaRAG is for agent memory and RAG pipeline builders. get this right. Whether you are working through running agentic rag in production or something adjacent, we publish what we have actually tested, including where it falls short.


