PromptisePromptise
PlatformSoonEnterprise
DocsGitHub
Talk to usGet started
Promptise - AI Framework LogoPromptise

The full-stack framework for agentic systems. Build with the framework. Run it on the platform. Launch it with our engineers.

pip install promptise

[01] Product

  • Framework
  • Platform (coming soon)
  • Enterprise
  • How it works
  • Contact

[02] Framework

  • The Agent
  • The Interface
  • The Harness

[03] Resources

  • Documentation
  • GitHub
  • Why Promptise
  • Use cases
  • Roadmap
  • Guides
  • Learning Paths
  • Questions

[04] Company

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

© 2026 Promptise by Manser Ventures. All rights reserved.

hello@promptise.com
← 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 24, 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

Agentic RAG is retrieval-augmented generation in which an AI agent runs the search. It decides when to look something up, writes its own queries and searches again until it can answer with sources. Classic RAG searches your documents once and hands the results to the model. This page shows how the two differ step by step, walks through a real run where the agent writes its own query for a two-part question, 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.

Classic RAG embeds and searches once, then gives the top-k passages and the question to the model. Agentic RAG lets the model write the search call, read the passages and search again until it has enough to answer with citations, or to say the documents don't say.
FigureClassic RAG searches once in a fixed pipeline; agentic RAG lets the model search until it can answer

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, and each search returns only two passages.

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 promptise import (
    Document,
    DocumentLoader,
    Embedder,
    InMemoryVectorStore,
    OpenAIEmbeddingProvider,
    RAGPipeline,
    RecursiveTextChunker,
    build_agent,
    tool,
)

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': 'monitor expense receipt submission timeframe monitor equipment purchase expense policy submit receipt timeframe'}
answer  Yes — monitors and keyboards can be expensed up to $300 per year, so your $250 monitor from the Berlin work trip qualifies (equipment.md). You must submit the receipt within 30 days of purchase (expenses.md).

The agent didn't search with the user's words. It wrote one query that names both parts, the monitor and the receipt deadline, and the two passages that came back, from equipment.md and expenses.md, covered both. Each claim in the answer names the document it came from. The instructions allow more searches, but the model decides whether to use them. In other runs, the same kind of single query returned travel.md instead of equipment.md, and the agent answered that the policies don't say whether a monitor can be expensed, without searching again.

Two things to notice. The query is a long, keyword-stuffed string: models often write queries this way, and with embeddings it usually works, but it is worth testing. And the failed runs still gave a cited, confident answer. That is why you should check retrieval and citations in your evals, not only whether the answer sounds right. 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: decide what the model sees on each step, return less from tools, and keep long runs small without losing the question.
  • // 02Advanced · 20 minContext Compaction for AI Agents: Trim vs SummarizeContext compaction for AI agents: drop, trim or summarize, what each keeps on a real transcript, why agents forget file paths, and how to compact safely.
  • // 03Intermediate · 16 minTool Result Too Large? Keep an AI Agent's Context SmallTool result too large for your AI agent? Page, filter and count at the tool, return errors instead of rows, and see what each design costs in tokens.
  • // 04Intermediate · 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.
  • // 05Intermediate · 18 minPer-User Agent Memory Isolation: Stop Leaks Between UsersWhy shared AI agent memory leaks between users, how per-user scopes and role-gated team notes stop it, and a canary test that proves the isolation works.
  • // 06Intermediate · 20 minHow to Test AI Agent Memory: Recall Evals in PythonHow to test AI agent memory with recall evals in Python: retrieval recall@k, then end-to-end cases for updates, dates, abstention and isolation.

Keep going.

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

All guidesLearning paths