AWS Builder Center
RAG from Basics to Advanced (Part 6): Query Routing, Multi-Hop Retrieval, and Agentic RAG

RAG from Basics to Advanced (Part 6): Query Routing, Multi-Hop Retrieval, and Agentic RAG

Where naive RAG breaks down, and the three patterns routing, multi-hop retrieval, and agentic/self-RAG that address it.

Series: RAG from Basics to Advanced (8 articles)

  1. …
  2. 6
    RAG from Basics to Advanced (Part 6): Query Routing, Multi-Hop Retrieval, and Agentic RAG This article
AWS DevOps Engineer | 7+ Yrs Cloud Automation | EKS, ECS, IaC | GenAI & AIOps Expert
This is Part 6 of a series that builds up Retrieval Augmented Generation (RAG) from the ground up
Everything covered so far Parts 2 through 5 describes what's usually called naive RAG (or vanilla RAG): a query comes in, gets retrieved against, and gets answered. One pass, straight through.
The natural interview question at this point: when does naive RAG actually fail? There are three common failure modes, and each one has given rise to a pattern that addresses it.

Why Naive RAG Breaks Down

  1. Not every query needs retrieval. If a user asks "what's 2+2" or just says "hi," retrieving is wasted effort and it risks injecting irrelevant context into the prompt for no reason.
  1. Some queries need multiple, sequential lookups. A question like "who founded the company with the highest revenue last quarter" can't be answered by a single retrieval, it needs one fact to find the next.
  1. Retrieval itself can simply be wrong. If the retrieved chunks are irrelevant, naive RAG will generate an answer from them anyway, with no mechanism to notice or correct it.
The three patterns below exist to address these three problems, in order.

Pattern 1: Query Routing

The idea: don't send every query straight into the retrieval pipeline. First decide whether this query needs retrieval at all and if it does, which source it should be retrieved from.
How it works:
  • A lightweight classifier (or the LLM itself) categorizes the incoming query, general knowledge vs. company-specific vs. something needing calculation, for example.
  • General knowledge ("what's the capital of France") goes straight to the LLM, retrieval is skipped entirely.
  • Company-specific questions go through the retrieval pipeline as usual.
  • If there are multiple knowledge bases (say, separate vector stores for HR docs and engineering docs), the router decides which one to query.
Why this matters: retrieval isn't free, every unnecessary retrieval call adds latency, cost, and the risk of pulling in irrelevant context. Routing makes sure retrieval only happens when it's actually needed.
A concrete example: a customer support bot with separate "billing" and "technical" knowledge bases. The router classifies the query's category first, then queries only the relevant knowledge base, which also makes retrieval itself more precise, since irrelevant sources are never searched in the first place.

Pattern 2: Multi-Hop Retrieval

The idea: some queries can't be answered by a single retrieval, they need a sequence of lookups, where the result of one retrieval determines the next query.
Example: "Who founded the company that had the highest revenue last year?"
This actually requires two separate facts:
  1. Which company had the highest revenue last year? (retrieval #1)
  1. Who founded that company? (retrieval #2 but this depends entirely on the answer to #1)
Why naive RAG struggles here: if you embed and retrieve against the whole question at once, no single document is likely to contain both facts, retrieval either fails outright or returns an incomplete, disconnected mix of context.
The multi-hop approach:
  1. Break the query into sub-questions (often via the LLM itself).
  1. Run the first retrieval get answer 1.
  1. Use answer 1 to construct the next retrieval query get answer 2.
  1. Combine both answers into the final response.
The point: multi-hop retrieval treats a complex question as a chain of simpler lookups, where each step's output shapes the next step's query, rather than expecting a single retrieval to magically capture a multi-fact question.
Trade-off: more latency (multiple retrieval and LLM calls) and more cost. This isn't run on every query typically it's triggered only when query routing detects that a question is genuinely multi-fact or sequential in nature.

Pattern 3: Agentic RAG / Self-RAG

This is the most advanced pattern here, the LLM itself decides whether to retrieve, when to retrieve, and whether what it retrieved is actually good enough to use.
The core difference from naive RAG: in naive RAG, retrieval is a fixed step it always happens, whether or not it's needed. In agentic RAG, retrieval is handed to the LLM as a tool it can choose to call much like an agent choosing which tool to use for a given task.
A typical loop looks like this:
  1. A query comes in.
  1. The LLM decides: does this need external information, or do I already know the answer?
  1. If retrieval is needed, the LLM generates its own retrieval query and calls the tool.
  1. It evaluates the retrieved content is this actually relevant, or should I retrieve again with a different query?
  1. If the content isn't good enough, it loops back to step 3 with a refined query.
  1. Once satisfied, it generates the final answer.
This is a loop, not a linear pipeline the model critiques and refines its own retrieval process.
Self-RAG specifically is a research technique where the model is trained to generate special "reflection" signals during generation essentially flagging things like "this needs retrieval," "this retrieved content is relevant," or "this generated claim is actually supported by the context." It gives the model a built-in ability to critique its own output.
The point: agentic RAG turns retrieval from a fixed pipeline step into a tool the model can choose to use, evaluate, and retry closer to how a person doing research would keep searching until they're satisfied with what they found.
Trade-off: the most flexible and potentially the most accurate approach, but also the least predictable latency varies depending on how many loop iterations run, and cost scales with the number of LLM calls per query. This needs a deliberate decision to use, not a default.

Quick Comparison

Pattern
Solves
Cost/Latency
Use When
Naive RAG
Simple, single-fact queries
Low
Default, for most queries
Query Routing
Unnecessary retrieval, wrong knowledge base
Low (one extra classification step)
Multiple knowledge bases, mixed query types
Multi-Hop Retrieval
Multi-fact, sequential questions
Medium–High
Complex queries needing chained lookups
Agentic/Self-RAG
Retrieval quality uncertainty, complex reasoning
High, unpredictable
High-stakes accuracy, research-style queries

Summary

The closing point worth remembering:
Naive RAG assumes every query needs exactly one retrieval pass advanced patterns exist because that assumption breaks down fast in production. Query routing decides if to retrieve, multi-hop decides how many times, and agentic RAG lets the model decide both, dynamically.


Next in this series (Part 7): Production challenges latency, caching strategies, cost management, and monitoring/observability for a RAG system running in the real world. This closes out the concepts phase of the series before we move into hands-on builds.

Series: RAG from Basics to Advanced (8 articles)

  1. …
  2. 6
    RAG from Basics to Advanced (Part 6): Query Routing, Multi-Hop Retrieval, and Agentic RAG This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article