Agentic RAG: Retrieval as a Tool the Model Chooses
A linear, one-concept-per-lesson path through Agentic RAG, retrieval as a tool the model chooses to call rather than a fixed pipeline step, from Gemini's native function calling to a complete multi-tool FastAPI service built entirely from scratch. 26 lessons · 3 tiers.
Prerequisites: Comfortable writing basic Python. Assumes you've done this site's Naive RAG course (or otherwise know what dense retrieval and embeddings are) - this course is framework-free and specifically about retrieval-as-a-tool: when an agent should retrieve, how many times, and what else it should be able to call instead.
Lessons use Google's Gemini free tier (gemini-3.5-flash-lite for chat, no embedding model needed) via Gemini's native function calling (google-genai). No Docker, no database, no extra account - GOOGLE_API_KEY in a .env file is the only setup.
Built directly on google-genai, Gemini's native function-calling SDK, no agent framework in between.

Beginner
Gemini function calling basics, wrapping retrieval as a tool, and a single-step agent loop that correctly decides when to call it.
Intermediate
Multi-step loops, query decomposition, persisted history, bounded iterations, cited multi-call answers, and the failure modes that come with all of it.
- 10Multi-Step LoopsGitHub
- 11Query Planning and DecompositionGitHub
- 12Passing Tool Results Back CorrectlyGitHub
- 13Persisting Conversation HistoryGitHub
- 14Bounding IterationsGitHub
- 15Prompting for Cited, Multi-Call AnswersGitHub
- 16Failure Modes of Agentic RetrievalGitHub
- 17Minimal Evaluation, Retrieve or NotGitHub
- 18Checkpoint: A Multi-Turn Notes AssistantGitHub
Advanced
A tool registry replacing if/elif dispatch, wrapping the agent as a FastAPI service, and a capstone.
- 19Where if/elif Dispatch Breaks DownGitHub
- 20Structuring run_agent()GitHub
- 21A Tool Registry PatternGitHub
- 22Optional Corrective Grading as a ToolGitHub
- 23Refactoring into tools() and run_agent()GitHub
- 24Wrapping It as a ServiceGitHub
- 25Capstone: A Complete Agentic RAG ServiceGitHub
- 26Where Agentic RAG Hits a WallGitHub