PromptisePromptise
Docs
GitHub
Promptise - AI Framework LogoPromptise

The foundation layer for agentic intelligence. Build, secure and operate autonomous AI systems with Promptise Foundry.

pip install promptise

[01] Foundry

  • MCPcast
  • The Promptise Agent
  • Reasoning Engine
  • MCP
  • Agent Runtime
  • Prompt Engineering
  • Execution Engine
  • Agent Identity

[02] Resources

  • Documentation
  • GitHub
  • Guides
  • Learning Paths
  • Questions

[03] Company

  • About
  • Terms of Service
  • Privacy Policy
  • Cookie Policy
  • Subprocessors

© 2026 Promptise by Manser Ventures. All rights reserved.

Open source · Python

← Guides> Memory, context and RAG

What Is Agentic RAG? How It Differs from Classic RAG

What agentic RAG is: an agent decides when and what to search, searches again if needed and cites sources. How it works, an example, RAG vs agentic RAG.

Level
Beginner
Reading time
7 min
Published
Oct 18, 2026
Last updated
Oct 18, 2026
By
Promptise Team
  • RAG (Retrieval-Augmented Generation)
Contents · 7 sections↓
  1. 01What is agentic RAG?
  2. 02How does agentic RAG work?
  3. 03An agentic RAG example
  4. 04Agentic RAG vs classic RAG and related terms
  5. 05Common misconceptions about agentic RAG
  6. 06Frequently asked questions
  7. 07Next steps

Classic retrieval-augmented generation (RAG) searches your documents once and hands the results to the model. Agentic RAG puts an agent in charge of the search. This glossary page defines agentic RAG, shows how it differs from classic RAG step by step, walks through a real run where the agent splits one question into two searches, and covers when the extra model calls are worth paying for.

[01]

What is agentic RAG?

Agentic RAG is retrieval-augmented generation in which an AI agent controls retrieval. Instead of one fixed search before the answer, the agent decides whether to search, writes its own queries, can search several times or several sources, checks what it found, and answers only when it has enough evidence, citing its sources.

Key takeaways:

  • Retrieval becomes a tool. In classic RAG your code always searches first. In agentic RAG the model calls a search tool when it decides it needs one.

  • The agent can try again. If the first results miss part of the question, it rewrites the query or searches another source.

  • It costs more per question. Every decision is a model call, so agentic RAG is slower and less predictable than one search and one answer.

  • Retrieved text is still untrusted. A document can contain instructions aimed at the model, and an agent with tools can act on them.

The term covers a range of designs. The survey *Agentic Retrieval-Augmented Generation* (Singh et al., 2025) describes it as embedding autonomous agents into the RAG pipeline, using reflection, planning, tool use and collaboration between agents. Research systems such as Self-RAG (Asai et al., 2023) trained models to decide when to retrieve and to critique their own output. Most production systems today use the simpler version shown here: a tool-calling agent with a search tool.


[02]

How does agentic RAG work?

Classic RAG, from the original paper by Lewis et al. (2020), is a fixed pipeline. Agentic RAG wraps the same retrieval step in an agent loop.

Text
1
2
3
4
5
6
7
8
9
10
 classic RAG (fixed pipeline)
   question ──▶ embed + search once ──▶ top-k passages + question ──▶ model ──▶ answer

 agentic RAG (agent loop)
   question ──▶ model ──▶ "search_policies('monitor expense')" ──▶ passages
                  ▲                                                   │
                  └──────────── enough to answer? no: search again ◀──┘
                  │ yes
                  ▼
                answer with citations, or "the documents don't say"

The retrieval index itself doesn't change. You still load documents, split them into chunks, embed the chunks and store them in a vector store. What changes is who calls search. In classic RAG, your code runs it with the user's exact words as the query. In agentic RAG, the model writes the query, which helps with questions that use different words than the documents, combine several topics, or need a fact from one document to know what to look up in another.

An agent can also have more than one source: a vector search over docs, a SQL tool for numbers, a web search for recent events. Picking the right source per question is a large part of what makes the approach useful.


[03]

An agentic RAG example

The example indexes five short policy documents with Promptise Foundry's RAG pipeline and gives the agent a search tool that returns the two best passages. The question has two parts, so one search of two passages can't cover it.

Pythonagentic_rag.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import asyncio

from langchain_core.tools import tool
from promptise import (
    Document,
    DocumentLoader,
    Embedder,
    InMemoryVectorStore,
    OpenAIEmbeddingProvider,
    RAGPipeline,
    RecursiveTextChunker,
    build_agent,
)

POLICIES = {
    "travel.md": "Travel. Hotels are reimbursed up to $180 per night in the US and "
                 "EUR 160 in the EU. Purchases made while traveling that are not travel "
                 "costs follow the policy for that kind of purchase.",
    "equipment.md": "Equipment. Laptops are ordered by IT, never expensed. Monitors "
                    "and keyboards can be expensed up to $300 per year.",
    "expenses.md": "Expense reports. Submit receipts within 30 days of purchase.",
    "leave.md": "Leave. Full-time staff get 25 days of paid leave per year.",
    "security.md": "Security. Report a lost device to IT within 24 hours.",
}


class DictLoader(DocumentLoader):
    async def load(self) -> list[Document]:
        return [Document(id=k, text=v, metadata={"source": k}) for k, v in POLICIES.items()]


class OpenAIEmbedder(Embedder):
    def __init__(self):
        self._provider = OpenAIEmbeddingProvider(
            model="text-embedding-3-small", api_key="${OPENAI_API_KEY}"
        )

    async def embed(self, texts: list[str]) -> list[list[float]]:
        return await self._provider.embed(texts)

    @property
    def dimension(self) -> int:
        return 1536


async def main():
    pipeline = RAGPipeline(
        loader=DictLoader(),
        chunker=RecursiveTextChunker(chunk_size=300, overlap=0),
        embedder=OpenAIEmbedder(),
        store=InMemoryVectorStore(dimension=1536),
    )
    await pipeline.index()

    @tool
    async def search_policies(query: str) -> str:
        """Search the company policy documents. Returns the 2 best passages."""
        hits = await pipeline.retrieve(query, limit=2)
        return "\n".join(f"[{h.chunk.metadata['source']}] {h.chunk.text}" for h in hits)

    agent = await build_agent(
        model="openai:gpt-5-mini",
        instructions="Answer from the company policies only. Search as many times as you "
                     "need, answer in two sentences, cite the source files, and say so if the "
                     "policies don't cover it.",
        extra_tools=[search_policies],
    )
    try:
        question = ("I bought a $250 monitor on my work trip to Berlin. Can I expense it, "
                    "and how long do I have to submit the receipt?")
        result = await agent.ainvoke({"messages": [{"role": "user", "content": question}]})
        for msg in result["messages"][1:]:
            for call in getattr(msg, "tool_calls", None) or []:
                print(f"search  {call['args']}")
            if msg.type == "ai" and msg.content:
                print(f"answer  {msg.content}")
    finally:
        await agent.shutdown()


asyncio.run(main())

Real output from one run with gpt-5-mini:

Output
search  {'query': 'expense monitor work trip Berlin equipment purchase expense policy monitor computer peripheral expense allowed'}
search  {'query': 'expense receipt submission timeframe submit receipts within days policy expense report deadline receipts submission timeframe'}
answer  Yes — monitors and keyboards can be expensed up to $300 per year, so your $250 monitor may be expensed (equipment.md; travel.md notes travel purchases follow the relevant purchase policy). Submit the receipt within 30 days of purchase (expenses.md).

The agent split the question into two searches, one for the monitor and one for the receipt deadline, and asked for both in the same turn. A classic RAG pipeline would have embedded the whole question once and hoped the top two passages covered both parts. Each claim in the answer names the document it came from.

Two things to notice. The queries are long, keyword-stuffed strings: models often write queries this way, and with embeddings it usually works, but it is worth testing. And the agent added a reason from travel.md to its answer. That one is correct here, but it shows why you should check citations in your evals, not only the final answer. Promptise also ships rag_to_tool(), which wraps a pipeline as a tool and marks retrieved text as data, not instructions. Agentic RAG in Python builds a full version with metadata filters, freshness and "I don't know" handling.


[04]

Agentic RAG vs classic RAG and related terms

Term

Who decides what to retrieve

Searches per question

Best for

---|---|---|---

Classic RAG

Your code, using the user's question

One

FAQ-style questions over one document set; low latency

Agentic RAG

The model, through a search tool

Zero to many

Multi-part questions, several sources, vague wording

Agent memory

The agent or the framework, from past conversations

Usually one, automatic

Remembering users and past facts

Long-context prompting

Nobody: everything goes in the prompt

None

Small, stable document sets that fit the context window

Fine-tuning

Nobody at run time: knowledge is in the weights

None

Style and format, not fresh facts

Agentic RAG is not always better. When the questions are simple and the corpus is clean, classic RAG gives the same answer with one model call instead of two or three. Start with the simple pipeline, as in RAG for beginners, and move to an agent when your evals show multi-part or badly worded questions failing. For memory, see AI agent memory.


[05]

Common misconceptions about agentic RAG

"Agentic RAG stops hallucinations." It reduces them when the documents contain the answer, and only if the instructions tell the agent to answer from the documents and to say when they don't cover the question. A model can still mix retrieved facts with its own guesses.

"More searches mean better answers." Each search adds tokens to the context, and long contexts make it harder for the model to use the right passage. Cap the number of searches and the passages per search. Context engineering for AI agents covers how to keep the context small.

"Retrieved documents are safe because they are ours." Anyone who can edit an indexed document, a support ticket or a wiki page can plant instructions for the model. That is indirect prompt injection. Scope what each user can retrieve and treat passages as data. See managing context and retrieval safely.

"You need a special framework for agentic RAG." Any agent that can call tools can do it. The search tool is an ordinary function that queries your index.


[06]

Frequently asked questions

What is the difference between RAG and agentic RAG?

Classic RAG runs one search with the user's question and passes the results to the model. Agentic RAG gives the model a search tool, so it decides whether to search, writes its own queries, can search several times or several sources, and answers when it has enough. Agentic RAG handles harder questions at a higher cost per answer.

When should I use agentic RAG?

Use it when questions often combine several topics, use different words than your documents, or need data from more than one source, such as docs plus a database. Stay with classic RAG when questions are simple, latency matters, and one search usually finds the answer.

Is agentic RAG more expensive than RAG?

Usually, yes. Each decision is a model call, so a question that needs two searches costs at least two or three model calls instead of one, and the retrieved passages add input tokens. Limit the number of searches and the passages per search to keep the cost predictable.

Does agentic RAG need a vector database?

No. The search tool can query a vector store, a keyword index, a SQL database or an API. Many agents use several. A vector store is the common choice for unstructured documents, and an in-memory store is enough for small corpora and tests.

How do you evaluate an agentic RAG system?

Test three things separately: whether retrieval returns the right passages for a set of known questions, whether the agent searches when it should and stops when it has enough, and whether each claim in the answer is supported by a cited passage. Evaluate AI agents shows how.


[07]

Next steps

  • Build it: Agentic RAG in Python.

  • Start simpler: RAG for beginners.

  • Keep the context lean: Context engineering for AI agents.

  • All guides on the topic: the memory, context and RAG hub.

  • Reference: RAG in the Promptise docs.

Contents

  1. 01What is agentic RAG?
  2. 02How does agentic RAG work?
  3. 03An agentic RAG example
  4. 04Agentic RAG vs classic RAG and related terms
  5. 05Common misconceptions about agentic RAG
  6. 06Frequently asked questions
  7. 07Next steps

Learning paths

Want more structure? Paths put guides in order, like a short course.

See the paths →

> Memory, context and RAG

Related guides

All guides in this topic →
  • // 01Intermediate · 26 minContext Engineering for AI Agents: Context Window ManagementContext engineering for AI agents in Python: keep what matters in long runs, trim the rest, and cut input tokens 18x. Real token counts per step.
  • // 02Intermediate · 18 minAI Agent Memory in Python: Short-Term and Long-TermGive your AI agent memory that lasts: chat history per session, long-term facts across sessions, kept per user. Python code with real output.
  • // 03Intermediate · 21 minAgentic RAG in Python: Give Your AI Agent a Search ToolBuild a RAG AI agent in Python: index your docs, give the agent a search tool, cite sources, and make it say "I don't know". Real code, real output.
  • // 04Intermediate · 23 minLLM Semantic Cache and Model Fallback in PythonReduce LLM API costs with a semantic cache and survive provider outages with model fallback. Real hits, tokens and a simulated outage, in Python.
  • // 05Intermediate · 22 minSelf-Improving AI Agent: Learn From Tool Failures in PythonBuild an AI agent that learns from failed tool calls without fine-tuning. Real before-and-after numbers, plus the risks: bad lessons, leaks, poisoning.
  • // 06Advanced · 10 minRAG Security: Stop Poisoned Documents and Prompt InjectionSecure a RAG pipeline: stop poisoned documents and indirect prompt injection, filter retrieval by permission, mark context, check answers. Real examples.

Keep going.

Browse every guide by topic and level, or follow a learning path that puts them in order.

All guidesLearning paths