Confident AI

Home / Blog / CI/CD Integration

← Back to Blog

Building LLM Quality Gates in Your CI/CD Pipeline

By the Confident AI Engineering Team · 12 min read

LLM CI/CD Quality Gates

An LLM application without evaluation gates in its deployment pipeline is a production incident waiting for a date. The mechanism for catching software regressions before they ship has existed for decades. What was missing was the equivalent mechanism for LLM behavioral regressions. This guide walks through building it.

We will cover GitHub Actions specifically, but the concepts apply equally to GitLab CI, Jenkins, and CircleCI. The Confident AI platform provides native integrations for all four. For teams not yet on Confident AI, we will also describe the underlying API approach so you can evaluate the pattern independently.

What "Quality Gate" Means for LLMs

In traditional software CI/CD, a quality gate is a check that must pass before a build can deploy: test coverage above 80%, no critical security vulnerabilities, latency P95 under a threshold. If the gate fails, the deploy stops automatically.

For LLM applications, the analogous gates are:

  • Hallucination rate below threshold — e.g., <5% on the evaluation dataset
  • Answer relevancy score above threshold — e.g., >0.85 on a 0-1 relevance scale
  • Faithfulness score in RAG context — claims grounded in retrieved documents
  • Red-team pass rate — adversarial probes must not succeed above a threshold
  • No regression vs. previous deploy — scores must not drop below a minimum delta

Each gate has a configurable threshold, and failing any gate blocks the deploy. This structure mirrors how code quality gates work in mature engineering organizations.

Step 1: Define Your Evaluation Dataset

Before writing any pipeline configuration, you need a dataset. An evaluation dataset for CI/CD gate purposes should have three properties: it should be representative of real user queries, it should have known-correct expected outputs for scoring, and it should be small enough to run in under 10 minutes.

50 to 200 test cases is a reasonable range for a CI gate dataset. Larger datasets are appropriate for nightly or weekly evaluation runs, but blocking deploys on a 2,000-case evaluation that takes 45 minutes will get the gate bypassed by frustrated engineers within a week.

Build your dataset in JSONL format with these fields per record: input, expected_output (optional for relevance metrics, required for factual consistency), and context (for RAG pipelines). The Confident AI platform accepts this format directly via API upload.

Step 2: Configure Your Evaluation Metrics

Not all metrics are relevant to all applications. A customer support chatbot needs different metrics than a code generation assistant or a document summarizer. Choose 3-5 metrics relevant to your use case rather than running every available evaluator. More metrics mean longer run times and noisier gate signals.

Configuration example for a RAG-based knowledge assistant:

metrics:
  - name: hallucination
    threshold: 0.05        # fail if >5% responses hallucinate
    weight: 1.0
  - name: answer_relevancy
    threshold: 0.80
    weight: 0.8
  - name: faithfulness
    threshold: 0.85        # RAG-specific
    weight: 1.0
  - name: contextual_precision
    threshold: 0.75
    weight: 0.6

gate_policy:
  fail_on_any: true        # any metric below threshold = gate fail
  regression_check: true   # also fail if score drops >10% vs baseline

Step 3: GitHub Actions Integration

The Confident AI GitHub Action runs your evaluation suite and returns a pass/fail exit code that GitHub Actions uses to determine whether the deployment workflow continues. Here is a minimal working configuration:

name: LLM Quality Gate

on:
  push:
    branches: [main, release/*]
  pull_request:
    branches: [main]

jobs:
  llm-evaluation:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Run LLM Evaluation Suite
        uses: confident-ai/evaluate-action@v2
        with:
          api_key: ${{ secrets.CONFIDENT_AI_KEY }}
          config_path: .confident/eval-config.yaml
          dataset_path: .confident/eval-dataset.jsonl
          fail_on_gate_failure: true

      - name: Upload Evaluation Report
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: llm-eval-report
          path: confident-eval-report.json

The fail_on_gate_failure: true parameter is the critical line. Without it, the action reports results but does not block the deployment. The report artifact gives you a per-test-case breakdown accessible from the GitHub Actions UI, which is essential for diagnosing gate failures quickly.

Step 4: Handling Gate Failures Without Causing Deploy Paralysis

The most common reason teams disable their LLM quality gates is that the gates start failing frequently and blocking deploys, and the team does not have clear processes for resolving failures. Design your failure response workflow before your first gate failure, not after.

A working pattern: when the gate fails, the action automatically opens a GitHub issue tagged llm-eval-failure with the evaluation report attached. The on-call engineer is paged. If the failure is caused by a known provider outage or rate limiting (not a model quality regression), the engineer can bypass the gate with an explicit override comment. All bypasses are logged and reviewed in the weekly quality review meeting.

This keeps the gate from becoming a frustration while maintaining an audit trail of every case where quality was waived.

Step 5: Calibrating Thresholds Over Time

Start with conservative thresholds: low enough to pass given your current model performance, strict enough to catch regressions. Your first goal is to establish a baseline, not to enforce perfection.

After 10 to 20 deploys of clean data, review the distribution of scores and tighten thresholds incrementally. The regression check — fail if scores drop more than X% vs. baseline — is often more useful than fixed absolute thresholds in early stages, because it catches deterioration without requiring you to define what "good" looks like before you have enough data to know.

The teams that sustain healthy evaluation gates long-term treat threshold calibration as a monthly review item, not a one-time setup decision. As described in our hallucination rate analysis, the distribution of what your users actually ask changes over time. Your gate thresholds should track that reality, not a snapshot from your launch week.

Confident AI's native GitHub Actions integration is available on all paid plans. Start a free 30-day trial to set up your first evaluation gate today.

← Back to Blog

Ready to Improve Your LLM Quality?

Start with the free Developer plan. No credit card required, and you'll have your first evaluation running in under 10 minutes.

Start Free Trial Explore Platform