Skip to content

M24: Agentic RAG and research agents (Part D: Agentic Systems)

In M7 and M8 you built RAG: retrieve some documents, then answer. It works until a question needs more than one look. "Who leads the team that runs billing?" cannot be answered in one retrieval, because you do not know to search for "the Payments team lead" until you have read that billing is run by the Payments team. Today you give retrieval to the agent as a TOOL, so it can search, read, search again with a smarter query, and answer with citations. That is a research agent, and it is where Part B (RAG) and Part D (agents) finally meet.

Today's win: a research agent that answers a multi-hop question a one-shot RAG cannot, by deciding to search more than once and citing the documents it used, all runnable offline.

Today you will

  • See where one-shot RAG (M7-M8) falls short: multi-hop questions and queries that need refining
  • Turn retrieval into a tool the agent calls inside the M9 loop (agentic RAG)
  • Watch the agent search, read, search again, then answer with citations to its sources
  • See it decide not to search when a question does not need the knowledge base

Run of show (about 60 minutes)

Time What we do
0:00 Hook: the question one-shot RAG cannot answer
0:05 The one idea: retrieval as a tool the agent controls (read notes.md)
0:12 Lab Part A: watch plain RAG fall short on a multi-hop question
0:28 Lab Part B: run the agentic research agent and read its searches and citations
0:50 Show: post the two answers side by side
1:00 Wrap

If you get stuck

  • Builds on M7-M8 (RAG and retrieval) and M9 (the agent loop). Reuse your .env key only for the optional live run.
  • The core lab runs offline, free, no key (a small local corpus and a keyword search stand in for the M7 vector store). No new libraries. Nothing here can harm your computer.
  • The search here matches on keywords, not deep meaning; the notes explain how embeddings (M7) make it semantic. The multi-hop behaviour is the same either way.

Optional challenge

Open starters/add_corpus_doc.py and add documents that create a three-hop question (billing to Payments team to its leader to who that leader reports to). A good research agent should search three times and cite all three documents. One-shot RAG cannot touch it.