SENTINEL BASE/ENGINEERING
Enterprise AI

Stop Deploying RAG on a Prayer: Architecting CI/CD Regression Gates

Small RAG changes can quietly hurt retrieval and answer quality. Here is a practical way to catch those regressions before they reach production.

We would never merge a change to a critical backend service without running automated tests.

If an engineer changed the payment service and said, “I tested it locally with two cards and it looks fine,” that pull request would not go very far.

So why do we sometimes treat RAG systems differently?

A small change to chunking, embeddings, retrieval settings, or even a system prompt can make a RAG application worse without causing a single obvious error.

That is the problem with silent regressions.

The API still returns 200. The application still runs. But the answers may become less accurate, important context may disappear, and hallucinations can slowly increase.

The answer is simple: treat RAG evaluation like any other part of your CI/CD pipeline. Test it before you deploy it.


Why RAG Regressions Are Easy to Miss

Traditional software tests usually have a clear pass or fail. A function either returns the expected result or it does not.

RAG is different. Small changes can affect the quality of the final answer in less obvious ways.

Here are a few common examples:

  • Changing chunk size: Moving from 512 to 256 tokens may reduce token usage, but it can also split an important explanation across two chunks.
  • Changing the embedding model: The new model changes how documents are arranged in vector space. Documents that used to appear in the top results may no longer rank as highly.
  • Increasing top-k: Going from k=3 to k=8 can help find obscure information, but it can also bring in more irrelevant content and give the model more noise to work with.
  • Editing the system prompt: A small prompt change can make the assistant more conversational while accidentally weakening the rules that keep answers grounded in retrieved context.

None of these changes necessarily cause an exception.

That is what makes them dangerous. Your CI pipeline can stay green while answer quality gets worse.


The CI/CD Regression Gate

A regression gate is an automated checkpoint in your CI/CD pipeline.

The idea is straightforward: when someone changes the RAG system, run a known set of evaluation tests. Compare the results with your current baseline. If the new version falls below the agreed threshold, stop the pull request.

The flow can work in GitHub Actions, GitLab CI, Argo, or any similar pipeline.

The important part is not the tool. The important part is that the evaluation happens automatically before the change reaches production.


What You Need to Build This

There are three main pieces.

1. A Curated Golden Dataset

Do not rely only on test questions generated on the fly.

Keep a version-controlled dataset of roughly 100–300 important test cases. These should represent real user questions, difficult edge cases, and problems you have seen in production.

Each test case should include:

  • The user question
  • The expected context, including the document IDs or passages that should be retrieved
  • A verified reference answer

This dataset becomes your RAG test suite.

As your product changes, keep adding important failures to it. A production bug should ideally become a regression test.

2. Clear Evaluation Metrics

Instead of asking one general question like “Does this answer look good?”, measure a few specific things.

Context precision and recall

Did the retriever find the right pieces of information? Did it also bring back a lot of irrelevant content?

Faithfulness

Can the claims in the final answer be supported by the retrieved context?

Answer relevancy

Did the answer actually address the user’s question, without adding unnecessary or made-up information?

These metrics give your team something concrete to track from one release to the next.

3. A Hard Deployment Gate

Once you have the metrics, set thresholds in your pipeline.

For example:

- name: Evaluate RAG Regression Gate
  run: |
    python -m eval.run_rag_suite       --dataset ./eval/golden_dataset_v2.json       --min-faithfulness 0.92       --min-context-recall 0.88       --max-latency-ms 2000

Now the pipeline has a real decision to make.

For example, if the minimum Context Recall is 0.88 and the new pull request scores 0.84, the evaluation command should fail. The pull request should not be merged until the regression is understood.

That is much safer than finding out after users have already seen the problem.


Use More Than One Evaluator

A single LLM judge can be useful, but it can also miss things.

Different judges can have different scoring patterns, and a single evaluator may focus too much on one aspect of the result.

For higher-assurance systems, use a small multi-agent evaluation panel.

Multi-Agent Evaluation Panel

Each evaluator has a clear job.

Retrieval Auditor

This agent looks at the user query and the retrieved chunks.

Its job is to answer one question: Did the retriever bring back the right information?

It should not be distracted by the final answer.

Fidelity Agent

This agent checks the generated answer against the retrieved context.

Its job is to catch claims that are not actually supported by the information the model received.

Adversarial Red-Teamer

This agent tries to break the system.

It can look for things such as prompt injection inside retrieved documents, leaked system instructions, policy issues, or unexpected changes in tone and behavior.

Consensus Arbiter

The final component combines the evaluation results and compares them with your historical baseline.

For example, you might decide that a regression larger than 2% on an important metric should block the release and send it back for engineering review.

The exact threshold will depend on your application. The important thing is that the rule is explicit and automated.


Engineering Discipline Beats Guesswork

LLM applications are probabilistic. That does not mean we should release changes based on intuition.

In a traditional application, we test business logic before shipping it. RAG systems need the same discipline, with an extra layer for retrieval and answer quality.

A good workflow is:

change → test → evaluate → compare with baseline → deploy

Not:

change → ask someone to try it → looks okay → deploy

The biggest shift is cultural as much as technical. Make RAG evaluation part of the engineering workflow, not something you do only after a production issue.

Build a useful golden dataset. Measure the important metrics. Run the checks automatically. And make the pipeline stop a release when the numbers say the new version is worse.

That is how you stop deploying RAG on a prayer.

Zulqurnan

Head of Engineering • Solution Architect

← Back to all technical memos