Overview

11 Correction, planning, and reasoning

Retrieval quality alone is not enough for real-world RAG systems because the core weakness of many pipelines is structural: they retrieve once, generate once, and never check whether the evidence is current, specific, or complete. In high-stakes settings such as compliance, legal research, or medicine, that single-pass design can turn a plausible match into a confident but wrong answer. The chapter argues that RAG must evolve from a passive pipeline into an agentic loop that can evaluate what it retrieved, decide whether it is sufficient, and try again when it is not.

To explain that shift, the chapter contrasts two complementary approaches. CRAG is the corrective approach: it adds a retrieval evaluator that audits the returned documents, filters noisy context, and triggers a fallback web search when the evidence is stale, ambiguous, or irrelevant. LevelRAG is the planning-first approach: it decomposes complex questions into atomic sub-queries, routes them to the most appropriate retrievers, and verifies whether the combined evidence fully answers the original request. CRAG is lightweight and easy to bolt onto existing systems, while LevelRAG requires a broader re-architecture of retrieval control flow.

The chapter ties these ideas to concrete failure modes in an enterprise compliance assistant, showing how staleness, long-tail entity confusion, and multi-hop reasoning gaps map to different architectural fixes. CRAG is best when the main problem is outdated or weak evidence that needs correction after retrieval, while LevelRAG is better when the question itself must be planned and decomposed before searching. In practice, the strongest systems combine both: planning to break the problem apart, correction to audit each sub-result, and verification to decide when the evidence is finally sufficient. The broader lesson is that production RAG is becoming less about a single retrieval step and more about controlled, iterative research.

From Passive Pipelines to Agentic Loops: The shift from linear execution to cyclical evaluation.
Strategic Selection: Mapping RAG failure points to architectural solutions.
CRAG Architecture: Using a retrieval evaluator to trigger corrective actions.
The Decompose-then-Recompose Algorithm: Distilling signal from noise in retrieved documents.
LevelRAG Architecture: Hierarchical planning decoupling logic from retrieval execution.
Solving the Compliance Scenario: How LevelRAG decomposes a complex query into atomic research tasks.

Summary

  • Retrieval is a loop, not a step: A vector database is not a magic box that contains all answers, and treating retrieval as something to audit and correct while it runs is what separates these systems from the pipeline in chapter 4.
  • CRAG audits what came back before generating: A retrieval evaluator grades the passages, filters the noise, and falls back to web search when the internal corpus is stale or thin.
  • LevelRAG plans before it searches: A high-level searcher splits a multi-part question into atomic sub-queries, because a single vector search cannot serve two information needs at once.
  • Different needs want different retrievers: Dense vectors hold up on thematic similarity, sparse search wins on exact entity matches, and the router picks per sub-query rather than per system.
  • Refusing to answer is a feature: A confidence score low enough to stop is worth more than a fluent answer nobody checked, which is why regulated industries adopted this pattern first.
  • The audit step outlived the paper's name: It ships as a reranker or an LLM-as-judge guard in most production stacks, rarely called CRAG.

FAQ

Why isn’t better retrieval quality enough to make a RAG system reliable?Better retrieval improves what the system can see, but it does not control what happens next. Chapter 11 argues that single-pass RAG still fails when the retrieved document is stale, only partly relevant, or insufficient for a multi-step question. Reliability also depends on validation, branching control flow, and the ability to retry or re-plan.
What is the main weakness of a single-pass Retrieve-then-Generate pipeline?Its weakness is that it makes one optimistic pass and then outputs whatever comes out, with no way to verify whether the retrieved context is actually correct, current, or complete. If retrieval or extraction fails, the system can silently hallucinate or give a wrong answer.
What does it mean for RAG to become “agentic”?Agentic RAG can make decisions about retrieval, evaluate what it retrieved, adapt based on intermediate results, and loop until the evidence is sufficient. In other words, it adds control flow, judgment, and self-correction instead of relying on a fixed one-query-one-answer pipeline.
What failure modes in RAG does this chapter focus on?The chapter emphasizes four recurring production failures: missing content or staleness (FP1), the right document being retrieved but ranked too low (FP2), incorrect specificity where a generic document replaces a specific one (FP6), and incomplete answers to multi-part questions (FP7). These failures motivate corrective and planning-based architectures.
How does CRAG help with stale or irrelevant retrieval?CRAG adds a Retrieval Evaluator that scores retrieved documents before generation. If the result is correct, it refines the context; if it is incorrect or ambiguous, it triggers fallback actions such as web search. This makes CRAG a “trust, but verify” style correction layer.
What is “Decompose-then-Recompose” in CRAG?It is CRAG’s method for cleaning retrieved context before generation. The system splits retrieved documents into smaller strips, scores each strip against the query, discards irrelevant pieces, and recomposes only the useful text into a tighter context for the generator.
When should you choose CRAG instead of LevelRAG?Choose CRAG when the main problem is retrieval validity, such as stale internal documents, noisy indices, or the need for live fallback to web search. It is a lightweight add-on for existing pipelines and works well for fact-checking and real-time validation.
What is the key idea behind LevelRAG?LevelRAG plans retrieval before it begins. It uses a High-Level Searcher to decompose a complex query into atomic sub-queries, routes each to the best searcher, summarizes the results, verifies whether the evidence is sufficient, and adds more queries if gaps remain.
Why does LevelRAG use different low-level searchers?Because different information needs require different retrieval modalities. LevelRAG can route exact entity or code lookups to sparse search, thematic or conceptual queries to dense search, and real-time facts to web search, improving precision and coverage over a single-index approach.
How do CRAG and LevelRAG work together in production?In a common composite design, LevelRAG handles planning and decomposition, each sub-query is retrieved separately, CRAG audits each sub-result for relevance or freshness, and then the High-Level Searcher verifies whether the combined evidence answers the original question. This gives both proactive planning and reactive correction.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Retrieval Augmented Generation, The Foundational Ideas ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Retrieval Augmented Generation, The Foundational Ideas ebook for free