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

← Learning paths> Agentic Engineering with Promptise Foundry
Lesson 43 / 71
61%

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.

Beginner7 minRAG (Retrieval-Augmented Generation)
All 71 lessons↓
  1. ✓What Is an AI Agent? Definition, How It Works, Examples
  2. ✓How to Build an AI Agent in Python (2026 Guide)
  3. ✓What Is an Agent Harness? Parts and How to Build One
  4. ✓System Prompt Best Practices for AI Agents in Python
  5. ✓Best LLM for AI Agents: Test and Switch Models in Python
  6. ✓AI Agent YAML: Define and Run an Agent From a Config File
  7. ✓Streaming LLM Responses with FastAPI: Tokens and Tool Calls
  8. ✓Claude AI Agent with MCP: Use Anthropic Models in Promptise
  9. ✓Gemini AI Agent with MCP: Use Google Models in Promptise
  10. ✓Azure OpenAI Agent with MCP: Use Deployments in Promptise
  11. ✓OpenRouter AI Agent with MCP: Many Models in Promptise
  12. ✓Ollama AI Agent with MCP: Run Local Models in Promptise
  13. ✓LLM Semantic Cache and Model Fallback in Python
  14. ✓What Is MCP (Model Context Protocol)? A Developer's Guide
  15. ✓What Is Tool Calling? LLM Function Calling Explained
  16. ✓MCP Tools vs Resources vs Prompts (With Python Examples)
  17. ✓How to Connect MCP Servers to Your AI Agent in Python
  18. ✓Build a Production MCP Server in Python (Step by Step)
  19. ✓MCP Transports: stdio vs Streamable HTTP vs SSE (Python)
  20. ✓FastAPI MCP Server: Turn Your FastAPI App into MCP Tools
  21. ✓OpenAPI to MCP: Turn Any REST API into an MCP Server
  22. ✓MCP Authentication in Python: API Keys, JWT and OAuth
  23. ✓Build an Authenticated MCP Server for Your AI Agent (Python)
  24. ✓MCP Security Best Practices: A Checklist for MCP Servers
  25. ✓Testing MCP Servers in Python: pytest Without a Live Server
  26. ✓Too Many MCP Tools? LLM Tool Selection, Measured
  27. ✓MCP Server Caching, Timeouts and Circuit Breakers in Python
  28. ✓MCP vs CLI for AI Agents: Tokens, Security, When to Use Each
  29. ✓AI Agent Audit Logging: Tamper-Evident Logs in Python
  30. ✓AI Agent Human in the Loop: Approve Tool Calls in Python
  31. ✓AI Agent Prompt Injection: How to Defend Against It
  32. ✓Build a Multi-Agent System in Python (and When Not To)
  33. ✓Context Engineering for AI Agents: Context Window Management
  34. ✓How to Deploy an AI Agent with Docker (2026 Guide)
  35. ✓LLM Tool Rate Limiting: Per-Client Limits for MCP Servers
  36. ✓MCP Long-Running Tasks: Background Jobs in Python
  37. ✓MCP Server Monitoring: Prometheus, OpenTelemetry and Logs
  38. ✓Python AI Agent Frameworks Compared: Which to Choose (2026)
  39. ✓Self-Improving AI Agent: Learn From Tool Failures in Python
  40. ✓AI Agent Identity: Authenticate Agents to MCP Servers
  41. ✓Code-Action Agents in Python: One Program vs 37 Tool Calls
  42. ✓Multi-Tenant AI Agents: Keep Each Customer's Data Apart
  43. 43What Is Agentic RAG? How It Differs from Classic RAG
  44. 44AI Agent Memory in Python: Short-Term and Long-Term
  45. 45Agentic RAG in Python: Give Your AI Agent a Search Tool
  46. 46AI Agent Reasoning Patterns in Python: 9 Patterns Tested
  47. 47Plan-and-Execute Agents in Python: Beyond the ReAct Loop
  48. 48Self-Modifying AI Agent in Python: Open Mode & Limits
  49. 49CrewAI Alternatives: 7 Options and How to Migrate (2026)
  50. 50Migrate from AutoGen: Agent Framework, Promptise and More
  51. 51What Is an LLM Guardrail? Types, Examples and Limits
  52. 52AI Agent Guardrails in Python: Block Injection, Redact PII
  53. 53AI Agent Code Execution Sandbox: Run LLM Code Safely
  54. 54AI Agent Production Checklist: What to Check Before Launch
  55. 55Approval Fatigue: Auto-Approve Safe AI Agent Actions
  56. 56What Is Human in the Loop AI? Approvals for AI Agents
  57. 57AI Agent Notifications: Webhook and Slack Alerts in Python
  58. 58AI Agent Observability: Trace Tool Calls, Tokens and Cost
  59. 59AI Agent Stuck in a Loop? How to Detect and Stop It
  60. 60How to Run, Debug and Deploy an AI Agent in Python
  61. 61AI Agent Cost Tracking: Tokens and Cost per Run and User
  62. 62How to Evaluate AI Agents: Evals, LLM Judges and pass^k
  63. 63AI Agent Cost Control: Budgets That Stop Runaway Spend
  64. 64How to Test LLM Prompts and AI Agents in Python
  65. 65AI Agent Evals in CI: Run Them on Every Pull Request
  66. 66Autonomous AI Agent Runtime: Budgets, Crash Recovery, API
  67. 67Event-Driven AI Agents: Webhook, Cron and File Triggers
  68. 68Durable AI Agents: Crash Recovery and Safe Resume
  69. 69Deploy AI Agents in Production: Long-Running Python Agents
  70. 70What Is an AI Agent Framework? When You Need One
  71. 71LangGraph Alternatives: 7 Options and How to Migrate (2026)

Lessons in this path

  1. ✓What Is an AI Agent? Definition, How It Works, Examples
  2. ✓How to Build an AI Agent in Python (2026 Guide)
  3. ✓What Is an Agent Harness? Parts and How to Build One
  4. ✓System Prompt Best Practices for AI Agents in Python
  5. ✓Best LLM for AI Agents: Test and Switch Models in Python
  6. ✓AI Agent YAML: Define and Run an Agent From a Config File
  7. ✓Streaming LLM Responses with FastAPI: Tokens and Tool Calls
  8. ✓Claude AI Agent with MCP: Use Anthropic Models in Promptise
  9. ✓Gemini AI Agent with MCP: Use Google Models in Promptise
  10. ✓Azure OpenAI Agent with MCP: Use Deployments in Promptise
  11. ✓OpenRouter AI Agent with MCP: Many Models in Promptise
  12. ✓Ollama AI Agent with MCP: Run Local Models in Promptise
  13. ✓LLM Semantic Cache and Model Fallback in Python
  14. ✓What Is MCP (Model Context Protocol)? A Developer's Guide
  15. ✓What Is Tool Calling? LLM Function Calling Explained
  16. ✓MCP Tools vs Resources vs Prompts (With Python Examples)
  17. ✓How to Connect MCP Servers to Your AI Agent in Python
  18. ✓Build a Production MCP Server in Python (Step by Step)
  19. ✓MCP Transports: stdio vs Streamable HTTP vs SSE (Python)
  20. ✓FastAPI MCP Server: Turn Your FastAPI App into MCP Tools
  21. ✓OpenAPI to MCP: Turn Any REST API into an MCP Server
  22. ✓MCP Authentication in Python: API Keys, JWT and OAuth
  23. ✓Build an Authenticated MCP Server for Your AI Agent (Python)
  24. ✓MCP Security Best Practices: A Checklist for MCP Servers
  25. ✓Testing MCP Servers in Python: pytest Without a Live Server
  26. ✓Too Many MCP Tools? LLM Tool Selection, Measured
  27. ✓MCP Server Caching, Timeouts and Circuit Breakers in Python
  28. ✓MCP vs CLI for AI Agents: Tokens, Security, When to Use Each
  29. ✓AI Agent Audit Logging: Tamper-Evident Logs in Python
  30. ✓AI Agent Human in the Loop: Approve Tool Calls in Python
  31. ✓AI Agent Prompt Injection: How to Defend Against It
  32. ✓Build a Multi-Agent System in Python (and When Not To)
  33. ✓Context Engineering for AI Agents: Context Window Management
  34. ✓How to Deploy an AI Agent with Docker (2026 Guide)
  35. ✓LLM Tool Rate Limiting: Per-Client Limits for MCP Servers
  36. ✓MCP Long-Running Tasks: Background Jobs in Python
  37. ✓MCP Server Monitoring: Prometheus, OpenTelemetry and Logs
  38. ✓Python AI Agent Frameworks Compared: Which to Choose (2026)
  39. ✓Self-Improving AI Agent: Learn From Tool Failures in Python
  40. ✓AI Agent Identity: Authenticate Agents to MCP Servers
  41. ✓Code-Action Agents in Python: One Program vs 37 Tool Calls
  42. ✓Multi-Tenant AI Agents: Keep Each Customer's Data Apart
  43. 43What Is Agentic RAG? How It Differs from Classic RAG
  44. 44AI Agent Memory in Python: Short-Term and Long-Term
  45. 45Agentic RAG in Python: Give Your AI Agent a Search Tool
  46. 46AI Agent Reasoning Patterns in Python: 9 Patterns Tested
  47. 47Plan-and-Execute Agents in Python: Beyond the ReAct Loop
  48. 48Self-Modifying AI Agent in Python: Open Mode & Limits
  49. 49CrewAI Alternatives: 7 Options and How to Migrate (2026)
  50. 50Migrate from AutoGen: Agent Framework, Promptise and More
  51. 51What Is an LLM Guardrail? Types, Examples and Limits
  52. 52AI Agent Guardrails in Python: Block Injection, Redact PII
  53. 53AI Agent Code Execution Sandbox: Run LLM Code Safely
  54. 54AI Agent Production Checklist: What to Check Before Launch
  55. 55Approval Fatigue: Auto-Approve Safe AI Agent Actions
  56. 56What Is Human in the Loop AI? Approvals for AI Agents
  57. 57AI Agent Notifications: Webhook and Slack Alerts in Python
  58. 58AI Agent Observability: Trace Tool Calls, Tokens and Cost
  59. 59AI Agent Stuck in a Loop? How to Detect and Stop It
  60. 60How to Run, Debug and Deploy an AI Agent in Python
  61. 61AI Agent Cost Tracking: Tokens and Cost per Run and User
  62. 62How to Evaluate AI Agents: Evals, LLM Judges and pass^k
  63. 63AI Agent Cost Control: Budgets That Stop Runaway Spend
  64. 64How to Test LLM Prompts and AI Agents in Python
  65. 65AI Agent Evals in CI: Run Them on Every Pull Request
  66. 66Autonomous AI Agent Runtime: Budgets, Crash Recovery, API
  67. 67Event-Driven AI Agents: Webhook, Cron and File Triggers
  68. 68Durable AI Agents: Crash Recovery and Safe Resume
  69. 69Deploy AI Agents in Production: Long-Running Python Agents
  70. 70What Is an AI Agent Framework? When You Need One
  71. 71LangGraph Alternatives: 7 Options and How to Migrate (2026)
← Path overview

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.

← PreviousMulti-Tenant AI Agents: Keep Each Customer's Data ApartNext lesson →AI Agent Memory in Python: Short-Term and Long-Term