Introduction
I have walked into more RAG postmortems than I can count where the team spent three weeks tuning the model while the retrieval layer was returning the wrong documents. The pattern is always the same: a demo that looked fine on ten PDFs, then quiet hallucinations in production once the corpus grew.
This note is the 12-step map I draw on whiteboards during engagements. Four stages, twelve steps, four failure points that kill most deployments. If you are comparing vanilla RAG to agentic RAG with sufficient context loops, this is the foundation those loops assume you already built.
Stage 1: Ingestion (steps 1–4)
Garbage in, garbage out. Ingestion is where most teams rush because it feels like plumbing. It is also where you poison every downstream step if you get it wrong.
- 01Step 1: Data sourcesCollect from every source the agent will need: Confluence, SharePoint, tickets, product docs, Slack exports. Miss a source and the agent will confidently answer from what it has, which is worse than saying it does not know.
- 02Step 2: Document loadingIngest into a pipeline that preserves structure. Tables, headers, and code blocks matter. A loader that flattens everything into one text blob destroys the semantics your chunker needs.
- 03Step 3: Meaningful chunkingChunk for meaning, not for token count. Fixed 512-token splits are fast to implement and expensive to debug. I prefer semantic boundaries: section headers, paragraph breaks, logical units. Overlap helps, but coherent units help more.
- 04Step 4: Metadata extractionExtract author, date, topic tags, product area, access level. Skipping metadata to save time is the second most common mistake I see. Retrieval without filters returns volume, not relevance.
Stage 2: Indexing (steps 5–6)
Indexing turns chunks into searchable knowledge. The embedding model and chunk boundaries matter more than which vector database logo is on the slide.
- Step 5: Embeddings. Pick an embedding model matched to your domain and language mix. Re-embed when you change chunking strategy.
- Step 6: Vector database. Store embeddings for semantic search. Pinecone, Weaviate, pgvector, Chroma: the choice is ops and cost, not magic. The output is indexed knowledge ready to query.
Stage 3: Retrieval (steps 7–9)
Retrieval is the make-or-break stage. I have seen teams burn Opus tokens on perfect prompts while step 8 returned forty chunks of noise. Fix retrieval first.
- 01Step 7: Query rewritingExpand intent, clarify meaning, rewrite the user query to match how content was indexed. A question about "refund policy" may need to match "returns and cancellations" in your docs.
- 02Step 8: Hybrid searchCombine semantic search with keyword search (BM25). Pure vector search misses exact product codes and error strings. Pure keyword search misses paraphrases. You need both.
- 03Step 9: RerankingReorder results by relevance, context, and intent. Returning top-k by cosine similarity alone is how you flood the LLM with irrelevant chunks. A cross-encoder reranker or LLM rerank step pays for itself quickly.
Stage 4: Generation (steps 10–12)
Generation only works if you close the loop. Steps 10–12 assemble context, produce a grounded answer, and measure whether you should ship it.
- 01Step 10: Context assemblyOrganize relevant chunks into a coherent prompt. Order matters: most relevant first, citations traceable, token budget respected.
- 02Step 11: LLM generationProduce an answer grounded in provided context. Instruct the model to cite sources and refuse when context is insufficient.
- 03Step 12: EvaluationMeasure faithfulness, relevance, and quality. Without step 12 you ship a demo that hallucinates quietly. Build an eval set from real user questions, not synthetic trivia.
Where agentic RAG fits
Agentic RAG adds a re-search loop when context is insufficient. The agent queries again with a refined question until it has enough to answer. That loop sits after step 9 (reranking), not instead of steps 1–8. Read the full comparison in agentic RAG vs vanilla RAG.
Memory type matters too. Large changing corpora belong in RAG (steps 5–6). Stable knowledge that fits in context belongs in CAG. See wrong memory, dead agent for the four-type decision rule.
Conclusion
Before you tune the model, audit the pipeline. Draw all twelve steps on a whiteboard, mark where your eval set fails, and fix the earliest broken step. RAG is infrastructure. Treat it that way and your agents stop guessing.


