liveBook · Manning

Retrieval-augmented generation

As explained in Vibe Engineering

Retrieval-augmented generation is a technique that retrieves relevant external information and supplies it as context for a language model's generated response.

Supplying an entire repository to a language model can overload its context window and bury useful information. Retrieval-augmented generation (RAG) instead searches for relevant external information and adds a curated slice to the prompt before the model responds. section 3.5.1

A repository-based RAG workflow follows three steps:

  • Index source files as searchable embeddings. section 3.5.1
  • Convert the developer’s query into an embedding and compare it with the index to retrieve relevant chunks. section 3.5.1
  • Add those chunks alongside the question so the model can generate a response using the retrieved context. section 3.5.1
Figure 3.7 Context-aware assistance flow. The developer's query is converted into an embedding, matched against the indexed codebase, and the most relevant chunks are injected into the prompt before the model generates its response.

Follow the query from embedding and repository matching through prompt augmentation and response generation. section 3.5.1

Fixing authentication

For an authentication request, retrieval can supply the login handler and its related tests instead of thousands of lines of unrelated code. Inspect the selected context: relevance is a retrieval decision, not a guarantee that the agent has everything it needs. section 3.5.1

When automatic retrieval repeatedly selects the wrong material, scope context manually: pin a file, mention a directory, exclude paths with an ignore file, or start a clean session if the current one has drifted. Arguing with the retrieval system in prose is less useful than explicitly selecting the context. section 3.5.1

RAG finds information relevant to the current query; it does not by itself preserve decisions across a long task. An agent can still lose earlier requirements or repeat fixed errors as conversation history exceeds its context window. Persistent, structured memory addresses a different problem, and retrieved help is less useful when the context is already bloated. section 3.5.2

How Vibe Engineering covers it

How deep it goes
Explains indexing, embedding-based retrieval, prompt augmentation, and manual context overrides, then distinguishes retrieval from persistent memory.
Examples
Uses an authentication repair request to retrieve a login handler and its related tests.
What you can do after
Evaluate retrieval context and intervene with file pinning, directory mentions, path exclusions, or a clean session when automatic selection drifts.
How it connects
Connects embeddings and context windows with context engineering and persistent memory.

Also explained in

Compare how 46 books explain retrieval-augmented generation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.