AI and dataGenerative AI

RAG in production: what actually breaks

Much of what breaks in a RAG assistant is the search that runs before the model writes anything. Here's what to fix first, and what to do when it gets an answer wrong or leaks one.

Cohash AI Practice July 2026 updated October 2026 12 min read 6 chapters 3-question check
part 2 of 5 · Data and AI that hold up in production
01 Telemetry feedback loop failures feed the golden set 02 Citations and refusals cite chunks, refuse guesses 03 Eval harness in CI blocks merges on regression 04 Hybrid retrieval BM25, dense, reranker 05 ACL-aware ingestion re-embed on update, tombstones

the ideaFive layers around the model. Much of the breakage, and most of the work, sits here.

after reading, you can
  • Trace a wrong answer to retrieval or generation first. Leave the prompt alone until you know which.
  • Stand up a golden-set eval that scores retrieval and answers separately. If either one drops, the build fails.
  • Make the index honor document permissions. Have it cite its chunks, and refuse if nothing relevant is returned.

You can build a RAGdefinitionRetrieval-augmented generation. The assistant runs a search over your company's files first, then a language model writes the answer from the passages it got back. Feed it the wrong files and you get a wrong answer, said with confidence. demo in an afternoon. A RAG system takes an engineering program, because the demo never has to answer one question. When the retriever hands back the wrong context, does anyone notice before the user does? If your company is putting an assistant in front of staff or customers, make sure someone can answer that before it goes live.

in plain wordsPractice guide

It's a search over your own files with a writer bolted on. If the search is wrong, so is the answer.

RAG stands for retrieval-augmented generation. When someone asks the assistant a question, a search runs over your own documents first: policies, manuals, contracts, tickets. The best passages go to a language model, and the model writes the answer from them. The model is often the easy part. The answer can only be as good as the passages the search found, and the search can only return what it was allowed to see. When the search picks the wrong pages, the model still writes a fluent, confident answer, and the reader has no way to tell.

think of it like this

Picture a new hire at a help desk with a filing room behind them. Someone asks a question, the hire pulls a few folders, reads them and answers. If they grab last year's price list, or a folder from the HR cabinet they were never meant to open, they'll still answer politely and with confidence. Most of the work is keeping the filing room current, locked properly and checked.

who should care
  • Owners rolling out an AI assistant
  • Teams building on their own documents
  • IT and data platform teams
  • Security and privacy leads
  • Support and HR teams using a bot
chapter 01

Why it matters to you

A wrong answer from an assistant doesn't look wrong. It reads well, it sounds sure of itself, and someone acts on it. An agent quotes last quarter's pricing to a customer. A manager follows a policy clause without the exception that sat in the next paragraph. The cost shows up later as a refund, a complaint or an audit finding, and nobody connects it back to the search step.

The worse failure is a leak. If the search index ignores who's allowed to read which document, anyone who can type a question can pull salary data, legal drafts or another customer's records out of it. OWASP's Top 10 for LLM applications lists this as its own risk, vector and embedding weaknesses (LLM08:2025), and it lists permission-aware vector stores among its recommended defenses. Treat the assistant as a new way into every document you load into it.

how it worksHow a RAG assistant produces one answerAny of these steps can go wrong and nobody would notice. Two of them, the permission filter and the refusal, are there to catch it.
  1. 01 Someone asks a question

    Someone on staff, or a customer, types a question. It often has a part number, an acronym or a policy name in it, and those are the hard ones to match.

  2. 02 The search finds candidate passages

    Two searches run side by side. Keyword search (BM25) catches the exact part code, and dense embeddings catch the question someone worded loosely.

  3. 03 Permissions filter the results

    Anything the person couldn't open in the source system gets dropped at query time. The access rules come from those systems, so someone has to keep the sync current.

  4. 04 A reranker picks the best few

    A second model, the reranker, re-scores what came back. The passages that actually answer the question go to the language model first, and the near misses usually drop out.

  5. 05 The model writes a cited answer

    The model is told to answer from those passages only and to cite each chunk it used. If an answer looks off, someone opens the citations and checks it in a few minutes.

  6. 06 Low confidence means no guess

    If nothing good came back, the assistant says "I don't have a good source for that" and stops there. A user who gets that goes and asks a person, which is what you want.

  7. 07 Everything is logged

    The question, the chunks retrieved and the citation clicks are logged. Failures go into the golden set the team tests every change against.

For engineers: retrieval fails silently, and the model papers over it. The wrong answers that cause trouble tend to be confident ones, written on top of the wrong passages. Check these causes first, before anyone touches the prompt.

  • Bad chunking splits a policy clause from its exceptions. Someone asks about the rule, gets the clause, and never sees when it doesn't apply.
  • Pure dense retrieval misses the exact identifiers, part numbers and acronyms keyword search would have caught.
  • A stale index serves last quarter's pricing with this quarter's confidence, and the model writes fluently over the wrong evidence.
chapter 02

What changes between a demo and production

side by sideThe demo and the production assistant can use the same model. Everything around it is different.
Demo
  • Dense embeddings only, fixed-size chunks
  • Index built once, never refreshed
  • Every document visible to every user
  • Answers without citations
  • Quality judged by a few hand-picked questions
Production
  • Hybrid BM25 and dense retrieval, plus a reranker
  • Chunks follow the document's structure
  • Index freshness is an SLO with an owner
  • ACL-aware retrieval at query time
  • Chunk-level citations and honest refusals
  • A golden set scores every change in CI

The fixes are unglamorous and well understood. Use hybrid retrieval that combines BM25definitionA classic keyword-ranking method. It reliably finds exact part numbers and acronyms that embedding search can miss. with dense embeddings, and put a rerankerdefinitionA second model that sorts whatever the search pulled back. Search grabs plenty of near misses, and the reranker moves the passages that actually answer the question to the top. over the candidate set. Chunk along the document's structure instead of a fixed token count. Treat index freshness as an SLO with an owner, so someone gets paged when it goes stale.

Watch for embedding driftdefinitionSwitch embedding models without re-indexing and this is what you get. The stored vectors and the new queries no longer share a coordinate system. as well. Swap the embedding model without re-indexing the corpus and every stored vector now sits in a foreign coordinate system. None of this is research, and it's what turns recall you assume into recall you can state.

chapter 03

What to do now

What to do now, by who you are

Business ownerbefore go-live
  • Ask the team how they'll know the assistant got worse. If the answer is "users will tell us", there's no eval harness yet.
  • Ask whether a staff member could pull a document out of the assistant that they can't open in SharePoint or the file share. Get the answer in writing.
  • Name one owner for index freshness and one for access sync. Without a name, both drift quietly.
Engineering and ML teamthis sprint
  • Build a golden set of a few hundred real user questions, each with known source passages and reference answers.
  • Score retrieval (recall@k, context precision) and generation (faithfulness, answer relevance) separately, so a chunking bug doesn't look like a prompt problem.
  • Run the golden set in CI on every embedding, chunking, prompt or reranker change, and block the merge on regression.
Data platform teamthis month
  • Re-embed documents when they change and write tombstones for deletions. A retracted policy should stop being retrievable the day it's retracted.
  • Add BM25 next to the dense index and a reranker over both. Then check part-number and acronym questions again.
  • Re-index the whole corpus whenever the embedding model changes. Mixed vectors give quietly wrong matches.
Security and privacybefore go-live
  • Check that retrieval enforces document ACLs at query time, and that ACL sync from the source systems has its own freshness SLO.
  • Treat retrieved documents as untrusted input. OWASP notes that RAG doesn't fully stop prompt injection, so a planted file with hidden instructions can still steer the answer.

Without an eval harness, every change to a RAG system is a guess that a demo signed off on. Pull the golden setdefinitionA fixed collection of real questions from users, with known source passages and reference answers. It's what every system change is scored on. from actual user queries. What the team imagines users ask is a different, easier test. Score each question on both axes separately, or you'll spend a week tuning prompts to fix what's actually a chunkingdefinitionCutting documents into pieces before indexing. Cut by a fixed token count and a policy clause can end up in one chunk while its exceptions sit in the next one. bug.

LLM-as-judge scoring keeps the harness affordable, with the usual caveats. Calibrate the judge against a human-labeled sample and pin its version. Then audit the cases where it disagrees with people. Nobody should read a passing harness as proof the system is good. What it does catch is a change that made things worse, and it catches it before your users do.

A RAG system with no evaluation harness is an anecdote generator. You only hear about the failures someone bothers to report.
rag-eval (example output)example output
# golden set runs on every change, like tests, because it is one
$ rag-eval run --golden-set v9 --diff main
retrieval  recall@5: 0.87  context precision: 0.74
generation faithfulness: 0.91  vs main: −0.04
regression: 12 questions worse · chunking suspected
✗ merge blocked · evidence attached to PR
chapter 04

Harden so the next one hurts less

What makes a RAG assistant dependable is everything around the model. Here's what we'd put in before anyone adds a second feature, roughly in the order we'd build it. Most of it is ordinary pipeline work.

The plumbing, in the order we'd build it

  1. 01
    Make retrieval permission-aware

    The index has to respect document ACLs at query time, or the assistant becomes the most efficient data-leak mechanism in the company. Syncing those ACLs from the source systems is its own pipeline, with its own freshness SLO.

  2. 02
    Keep ingestion current

    Documents change, so the pipeline re-embeds on update and writes tombstones for deletions. Without that, what you have is an archive that still answers questions.

  3. 03
    Cite the chunks behind every answer

    Each answer cites the chunks it used. When someone reports a wrong answer, the on-call engineer opens the citations and sees why within minutes. Without them, the team ends up arguing about the model.

  4. 04
    Refuse when the sources are weak

    If retrieval confidence is low, the assistant says "I don't have a good source for that" and stops. A scripted refusal costs one annoyed user. A fluent guess can cost a customer.

  5. 05
    Close the loop with telemetry

    Log each query, the chunks retrieved and the citation clicks. When an answer fails, add that question to the golden set. Over months, that loop does more for quality than switching models.

  6. 06
    Split stores by audience

    OWASP recommends strict logical and access partitioning of datasets in the vector store. In practice, HR, legal and customer data sit in separate collections. If one filter breaks, the damage stays inside one of them.

chapter 05

If it goes wrong

If the assistant gives a wrong or leaked answer

Sooner or later someone screenshots a bad answer. Work through these phases in order. Citations and query logs make this a morning's work. Without them it's guesswork.

  1. 01Containfirst hour
    • If the answer exposed data the person shouldn't see, save the query logs first. Then pull the affected collection from the index or switch the assistant to refuse-only, because leaving it up keeps the leak open.
    • If the answer was wrong but harmless, leave the assistant running. Log the question and give it an owner, so it doesn't get lost in the support queue.
  2. 02Investigatefirst day
    • Pull the query log: the question, the chunks retrieved and the citations shown. Check whether the right passage was retrieved at all.
    • If the right passage wasn't there, it's a retrieval problem: chunking, index freshness, a missing tombstone or an ACL sync gap. Leave the prompt alone.
    • If it was there and the answer still got it wrong, it's a generation problem. Check faithfulness on that question.
    • For a leak, keep the query logs and use them to list who actually retrieved those chunks while the ACL was wrong, and who else could have.
  3. 03Fixdays 1 to 3
    • Fix the cause you found: re-chunk, re-index, tombstone the retracted document or repair the ACL sync. Then confirm the bad chunk can't come back.
    • Add the failing question to the golden set and confirm the fix in CI before it ships.
  4. 04Tell peopleas soon as known
    • Tell the people who got the wrong answer what the right one is. Anyone who already acted on it, say by quoting a price, needs to hear first.
    • If personal or customer data was exposed, bring in privacy and legal the same day. Depending on the data and the jurisdiction, you may have to notify regulators or customers.
  5. 05Learnwithin two weeks
    • Write down which check would have caught it earlier: a golden-set question, a freshness alert or an ACL test. Build that check, so the next failure trips CI before a user sees it.
    • Look at the refusal threshold again. If the assistant answered on weak sources, it should have said it didn't know, and someone needs to tighten the setting.
chapter 06

What this can look like in practice

What this can look like in practice

01 Part-numberquery 02 Dense searchonly wrong part 03 BM25 +reranker exact match 04 Cited answer
scenario 01Medium risk
A distributor's parts assistant
the setup
A parts distributor gives its counter staff an assistant over product manuals and spec sheets. Retrieval is dense embeddings only, and nobody scores it on its own.
what happens
Questions with exact part numbers keep coming back with passages for similar-looking parts. The model writes a confident answer from them, and a few wrong orders go out before anyone links them to the assistant.
what to do
Add BM25 next to the dense index and a reranker on top. Put the real part-number questions from the logs in the golden set, so retrieval recall gets measured separately from the answers.
01 Policyretracted 02 Tombstonewritten ingestion job 03 Index search 04 Old rulequoted
scenario 02Medium risk
An insurer's internal policy bot
the setup
A mid-size insurer loads its underwriting policies into an assistant. The index was built once at launch, and the ingestion job only adds new files.
what happens
A policy was retracted last week, but its chunks are still in the index. An underwriter asks a question and gets the old rule back, cited and confident.
what to do
Change ingestion to re-embed on update and tombstone deletions. Give index freshness an owner and an SLO, and add the retracted-policy question to the golden set.
01 Employeequestion 02 Shared index all drives 03 ACL filter query time 04 HR salaryfile
scenario 03High risk
A company-wide assistant over shared drives
the setup
A services firm points one assistant at its file shares and wiki. The index stores the text and skips the permissions, because that was quicker for the pilot.
what happens
A junior employee asks about bonus bands and gets an answer quoting an HR spreadsheet they could never open directly. Everyone else with the assistant could have done the same.
what to do
Take the HR content out of the index today. Then rebuild retrieval to filter by synced ACLs at query time, and check the logs for who else retrieved those chunks.

We put an evaluation harness into NLP and LLM work from day one, so nobody has to take a demo on faith. The golden set and the CI gate usually come first. Then we fix retrieval permissions and ingestion around whatever model the team already picked. If your pilot looks fine in demos and nobody can say how often it's wrong, ask us to start there.

key takeaways

What to take from this

  1. 01

    Assume retrieval fails silently. Hybrid search, reranking, structure-aware chunking and an index freshness SLO are where you start, before any polish.

  2. 02

    Build a golden-set eval harness before the second feature, score retrieval and generation separately, and gate merges on regression.

  3. 03

    Ship the plumbing. Make retrieval ACL-aware and cite at chunk level. When confidence is low, refuse honestly. Feed failures back into the golden set with telemetry.

fact-checked October 2026 against vendor and official documentation · where to go next
  1. NLP practice
  2. Book a 30-minute working session with a senior engineer
01What is RAG, in plain words?

It's an assistant that looks up passages in your own documents first and then has a language model write the answer from them. The model doesn't know your business. Everything it says about your policies or products comes from whatever the search handed it.

02Could our assistant show someone a file they can't open themselves? We're worried about HR data.

Yes, if the search index ignores document permissions. Ask your team whether retrieval checks each user's access at query time, and how quickly a permission change in the source system reaches the index. If nobody can answer, assume it leaks.

03Will a bigger or newer model fix wrong answers?

Often not. Many wrong answers come from the search handing the model the wrong passages, and a better model just writes over them more fluently. Score retrieval on its own first, and change the model only if the right passages were there and the answer was still wrong.

next step

Tell us what you're running. We'll tell you what we'd do first.

A 30-minute working session with a senior engineer. No slides.

useful to bring
  • The platform and the version you're on
  • Where you need to get to, and by when
  • What's custom: rules, plugins, integrations
  • Any audit finding or deadline driving it