AI Agents for Beginners - 5. Agentic RAG

Agentic RAG — how LLMs autonomously decide when and how to retrieve information, iterate with a maker-checker loop, self-correct, and deliver high-quality grounded responses.
June 8, 2026

AI Agents for Beginners - 5. Agentic RAG

This post summarizes key takeaways from Lesson 05 of Microsoft's AI Agents for Beginners course.

What is Agentic RAG?

Agentic RAG (Retrieval-Augmented Generation) is a new AI paradigm where LLMs retrieve information from external sources while autonomously planning their next steps.
Key differences from traditional RAG:
Traditional RAGAgentic RAG
Retrieval MethodFixed pipeline (retrieve → generate)LLM autonomously decides when and how to search
IterativityGenerates response after a single searchEvaluates results and repeats retrieval if needed
Query HandlingStatic queryRewrites query or changes approach upon failure
OrchestrationRequires complex prompt chainsSimple LLM call → tool use loop
This iterative Maker-Checker approach enhances accuracy, handles flawed queries, and ensures high-quality results.

The Core Loop

At the heart of Agentic RAG is an iterative loop of LLM call → tool use → LLM call → ….
Agentic RAG Core Loop
Mermaid
flowchart TD Start["User Goal (Prompt)"] --> LLM["LLM\nAnalyze Goal & Plan"] LLM --> Decision{Information\nSufficient?} Decision -->|"No"| Tool["Invoke Tool / Retrieval\n(Vector Search, SQL, API)"] Tool --> Assess["Assess Results\n& Update Memory"] Assess --> Refine{Need Query\nRefinement?} Refine -->|"Yes"| Tool Refine -->|"No"| Decision Decision -->|"Yes"| Response["Generate Final Response"]
Steps in the loop:
StepDescription
Initial CallThe user goal (prompt) is passed to the LLM
Tool InvocationIf information is insufficient, an appropriate tool such as vector search, SQL, or an API is selected and invoked
Assessment & RefinementEvaluates returned data; if insufficient, refines the query or tries another tool
Repeat Until SatisfiedRepeats the cycle until sufficient information is gathered
Memory & StateRemembers results from each step to avoid redundant loops and make better decisions

Owning the Reasoning Process

A defining characteristic of an agentic system is that it owns its reasoning process.
While traditional RAG follows human pre-defined paths, Agentic RAG autonomously decides the sequence of steps based on the quality of information.
For instance, when tasked with creating a product launch strategy, the agent autonomously decides to:
  1. Search for current market trend reports using Bing Web Grounding
  2. Identify competitor data using Azure AI Search
  3. Correlate past internal sales metrics using Azure SQL Database
  4. Synthesize everything into a coherent strategy using Azure OpenAI Service
  5. Evaluate gaps and inconsistencies in the strategy, repeating retrieval if necessary
All these steps are decided by the model itself, without human pre-scripting.

Building a RAG Agent

Creating a Search Tool

By wrapping external data sources into tools, the agent can invoke retrieval whenever needed:
search_tool.py
python

Basic RAG Agent

Instruct the agent to always search first, generating responses grounded in the knowledge base rather than relying solely on its training data:
rag_agent.py
python

Maker-Checker Pattern

Iterative retrieval is a core strength of Agentic RAG.
The agent performs multiple searches to verify and supplement initial results:
  1. Maker step — Retrieves initial information and drafts a response
  2. Checker step — Performs additional searches to confirm details or fill in gaps
maker_checker_agent.py
python
Maker-Checker Pattern Flow
Mermaid
zenuml title Maker-Checker Pattern Flow User->Agent: budget $175/day, travel in April Agent->Tool: search_travel_knowledge(April travel) Tool->Agent: initial destination results Agent->Agent: evaluate completeness Agent->Tool: search_travel_knowledge(Barcelona) Tool->Agent: detailed info with cost and season Agent->Tool: search_travel_knowledge(Paris) Tool->Agent: detailed info with cost and season Agent->Agent: compare and verify against budget Agent->User: verified recommendation with details

Handling Failure Modes and Self-Correction

The autonomy of Agentic RAG includes robust self-correction mechanisms.
Even when irrelevant documents are retrieved or queries fail, the system recovers on its own:
Failure ModeSelf-Correction Method
Irrelevant ResultsTry a new search strategy, rewrite the query, or explore alternative datasets
Flawed QueriesDebug reasoning steps with diagnostic tools and verify retrieved data accuracy
Repeated FailuresFlag uncertainty and request human review. Learn from feedback
Through this iterative and dynamic approach, the agent goes beyond a simple one-shot system to learn from mistakes within a session and continuously improve.

Boundaries of Agency

While Agentic RAG is powerful, it is distinct from Artificial General Intelligence.
Its capabilities as an "agent" are bounded by the tools, data sources, and policies provided by human developers:
BoundaryDescription
Domain-Specific AutonomyOperates to achieve user-defined goals within a known domain. Improves outcomes via query rewriting and tool selection
Infrastructure-DependentLimited strictly to the scope of tools and data integrated by developers. Cannot transcend these boundaries without human intervention
Respect for GuardrailsEthical guidelines, compliance rules, and business policies are maintained at all times

Practical Use Cases

Use CaseDescription
Correctness-First EnvironmentsIn compliance reviews, regulatory analysis, and legal research, iteratively verifies multiple sources to produce thoroughly validated answers
Complex Database InteractionsAutonomously refines failed queries when processing structured data with Azure SQL or Microsoft Fabric
Extended WorkflowsContinuously adapts strategies across long-running sessions as new information emerges

Governance, Transparency, and Trust

As agents reason more autonomously, governance and transparency become increasingly vital:
  • Explainable Reasoning — Provide audit trails of queries executed, sources referenced, and reasoning steps taken. Maintain transparency with Azure AI Content Safety and Azure AI Tracing
  • Bias Control — Calibrate retrieval strategies to utilize balanced, representative data sources, and regularly audit for bias and distortion patterns
  • Human Oversight — Human review is indispensable for sensitive tasks. Agentic RAG does not replace human judgment, but rather complements it by presenting thoroughly vetted options

Summary

Lesson 05 Summary
Mermaid
flowchart LR Root["Agentic RAG"] Root --> Core["Core Loop"] Root --> Pattern["Maker-Checker"] Root --> Self["Self-Correction"] Root --> Gov["Governance"] Core --> C1["LLM call → Tool → Evaluate"] Core --> C2["Maintain Memory & State"] Core --> C3["Own Reasoning Process"] Pattern --> P1["Maker: Initial Search & Draft"] Pattern --> P2["Checker: Re-search & Verify"] Self --> S1["Query Rewriting"] Self --> S2["Try Alternative Tools"] Self --> S3["Human Oversight Fallback"] Gov --> G1["Explainable Reasoning"] Gov --> G2["Bias Control"]
  • Agentic RAG moves beyond the fixed pipeline of traditional RAG, allowing the LLM to autonomously decide retrieval strategies
  • The Maker-Checker loop iteratively verifies initial findings to enhance accuracy
  • In case of failure, robust self-correction is enabled via query rewriting, tool substitution, and human oversight fallbacks
  • As autonomy increases, trustworthy governance must be upheld through Explainable Reasoning, Bias Control, and Human Oversight
Jooojub
System S/W engineer
Explore Tags
Series
    Recent Post
    © 2026. jooojub. All right reserved.