RAG Fundamentals
Without retrieval, the agent answers from memory, and memory is what it got wrong.
What it is
Retrieval-Augmented Generation (RAG) is a pattern that gives an LLM access to external knowledge it was not trained on. Instead of relying purely on its internal weights, the system:
- Retrieves relevant information from a database based on the user's query.
- Augments the prompt by injecting that retrieved information into the context window.
- Generates the final answer using the newly provided facts.
Why it matters in production
LLMs have a static knowledge cutoff and cannot access your private codebase, Slack messages, or documentation. If you ask an agent to "debug the billing service," it will hallucinate unless it can read the billing service code.
RAG grounds the LLM in your data. In production it reduces hallucinations, lets answers cite their sources, and lets an agent use proprietary data without fine-tuning the model.
How Agenthood implements it
Agenthood's RAG architecture starts with KnowledgeGraphStore for structural retrieval. The Retriever and Indexer components are implemented at src/rag/ (shipped in Phase 1):
The agent retrieves the facts before it answers.
Hands-on example
The structural retrieval layer (KnowledgeGraphStore) is available now, alongside the indexing and embedding pipeline (Indexer, ProjectIngestion, ChunkStrategy). There is no dedicated CLI subcommand: use the API directly:
Further reading
- ADR-010: LanceDB for Vector Storage
src/rag/KnowledgeGraphStore.ts: bidirectional graph store (shipped)src/memory/VectorStore.ts: LanceDB vector store (shipped)- IBM: What is RAG?: foundational overview of the RAG pattern