Skip to content
QUEST & CROSSFIRE

Blog  / AI Engineering

Why Vibe-Coded RAG Fails (And How to Architect It Properly)

By Asheesh Ranjan Srivastava · · 5 min read Includes video

Watch the video above to see the live 25-minute requirements interview and repo commits in action. This companion piece distills the reusable pre-code RAG readiness checklist, 3-state answer contract, and ADR-001 index-isolation pattern so you can apply them before writing line one of your own retrieval system.

A single prompt can generate a working RAG prototype with a chat UI in five minutes. That speed hides a trap: when the prototype cites a source it never read, or claims a paper lists seven failure points and only prints six, you cannot fix it because you never wrote down what “correct” looks like.

When I started rebuilding my RAG system from scratch as if an engineering team depended on it, I intentionally wrote zero code in phase one. Below is the exact specification architecture that replaced guesswork with measurable pass/fail criteria.

The Pre-Code RAG Readiness Checklist

Before choosing a vector database, chunk size, or web UI, five decisions determine whether a RAG system can be trusted or only demoed:

Pre-Code GateCommon Vibe-Coded DefaultProduction-Grade RuleWhy It Matters
Source governanceAuto-crawl or auto-reindex any modified fileFrozen, licence-checked copies; file fingerprint (R7/R8) halts indexing until a lead re-approves changesPrevents silent ingestion of unapproved or broken source edits
Document boundariesSplit every PDF page into its own chunkPreserve multi-page lists and sections across PDF page breaks (R6)Stops the exact bug that turned a 7-item list into 6
Evaluation labelsLabel ground-truth answers by chunk IDLabel hand-written eval questions by file + sectionChunk IDs break the moment your chunking strategy changes
Pass markJudge answers by how fluent they soundFix a numeric bar upfront: >= 8/10 answerable sources right + not found on an unanswerable queryTurns quality from an opinion into a countable score
Interface scopeBuild the chat web UI on day oneCLI/terminal first; defer UI, approval screens, and LLM-as-judge scoring to out-of-scopeA polished UI hides broken retrieval underneath

The 3-State Answer Contract

Most prototype RAG apps collapse every response into one confident paragraph, falling back on the LLM’s parametric memory whenever retrieval comes up empty. Defining an explicit three-state output contract eliminates that ambiguity before any prompt is written:

Answer StateTrigger ConditionRequired BehaviorForbidden Behavior
foundMatching approved passages cover the queryAnswer strictly from retrieved passages and cite exact sourcesAdding uncited facts from model memory
not foundIndex is healthy, but approved sources do not cover the queryExplicitly state that the approved sources do not answer the questionGuessing or answering from pretraining knowledge
unavailableIndex, embedder, or dependency error occursFail loudly with an actionable system/configuration errorPretending the answer was simply not found

Keeping not found and unavailable separate is critical for evaluation: an infrastructure bug must never masquerade as a retrieval miss.

Keeping Premature Choices Out of the PRD

When using AI coding assistants for planning, they routinely try to settle implementation details (chunk size, hybrid vs. dense search, vector store) before a single test question exists.

To stop accidental architecture lock-in, every undecided choice moves out of the PRD into an Open Decisions table tracking four columns: what the decision serves, when it will be settled, what data is needed first, and what blocks it. Two edge cases surfaced immediately once that table existed:

  • Stale documentation discipline: When evaluation questions are committed mid-planning, open-decision tables go stale instantly. Tracking the fix as an explicit follow-up commit keeps history auditable.
  • Multi-source scoring rules: If an evaluation question expects two source files (as questions 9 and 10 did in my 11-question set), your pass mark changes depending on whether returning one source counts as a hit or only both. Logging that ambiguity before running the baseline prevents moving the goalposts after seeing scores.

Once a row in the table has enough evidence to settle, it leaves the table and becomes an Architecture Decision Record (ADR).

ADR-001 Pattern: Preventing Silent Embedding Model Mismatches

To compare two embedding models fairly on the same 11-question benchmark (OpenAI embeddings in the cloud vs. a local Jina embedding model), one index must never mix vectors from different models. Three storage architectures exist:

Index StrategyTrade-OffVerdict
Single shared index (rebuild on switch)Re-embeds entire corpus every time you compare modelsSlow, error-prone during side-by-side evals
Embed on the fly (no persisted index)Zero index managementUnusable latency and repeated API cost
One isolated index per modelSlightly more disk space; zero rebuilds during evaluationSelected (ADR-001, updates R10)

Isolating indexes solves rebuild friction, but introduces a subtle failure edge: what prevents a query embedded by Model A from being searched against Model B’s index?

If the two models have different vector dimensions, search crashes loudly. Worse, if their dimensions happen to match, similarity search returns plausible-looking scores that are mathematically meaningless, causing your benchmark to blame the embedding model for a wiring bug.

The guardrail contract in ADR-001:

  1. Every persisted index carries an immutable metadata label naming the exact embedding model that built it.
  2. At query time, search reads the index’s model label to select the matching embedder.
  3. If the query embedder and index label still disagree, search aborts immediately in the unavailable state with an error naming both models, never silently returning not found.

The Human Reviewer’s Habit in AI-Assisted Systems

Building specs with AI is fast, and in my first session the AI genuinely caught a real bug I had missed (PDF per-page chunking slicing a list across a page break) and flagged an eval scoring gap on multi-source questions.

Yet twice in the same session, its output looked finished while hiding a real failure edge: missing the governance re-approval rule (R7/R8) and leaving embedding-model mismatches unguarded until I asked “what happens on the other side of this?”

That is the working rule I am carrying into design, specs, and test-first code in the rest of this build: let the AI draft fast, then inspect every boundary where a quiet failure could look like a valid answer.


Links & Resources

Scroll to Top