Capabilitiesretrieval-augmented generationretrieval-augmented agents

What Is RAG (Retrieval-Augmented Generation)?

RAG lets AI agents retrieve relevant documents or data before generating a response — grounding answers in your knowledge base instead of model training data alone.

2 min readUpdated rag.md

RAG (Retrieval-Augmented Generation) is a pattern where an AI system retrieves relevant information from an external knowledge base before generating a response. Instead of relying solely on what the model learned during training, the agent grounds its answer in your documents, database, or vector store.

How RAG works

  1. Index — Documents are chunked and embedded into a vector store
  2. Retrieve — When a query arrives, similar chunks are fetched by semantic search
  3. Augment — Retrieved content is injected into the model's prompt as context
  4. Generate — The model produces a response grounded in the retrieved material

RAG vs. fine-tuning

RAGFine-tuning
UpdatesAdd documents anytimeRetrain the model
CostLower, pay per queryHigher upfront
Best forDynamic knowledge basesStyle, format, domain behavior
CitationsCan trace to source docsOpaque

Most production agents use RAG (or similar retrieval) for knowledge that changes frequently — product docs, policies, customer records.

Common RAG pitfalls

  • Chunking too large or too small — hurts retrieval precision
  • No reranking — top-k vector matches aren't always the best context
  • Stale indexes — documents update but the vector store doesn't
  • Over-retrieval — stuffing too much context into the prompt wastes tokens and confuses the model

See Agent Memory for how RAG fits into the broader memory architecture.