🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

CI/CD Pipelines for LLM Applications

LLMOps in ProductionLLM CI/CD PipelinesđŸŸĸ Free Lesson

What changes in a pipeline when the logic is a model

A conventional deployment pipeline assumes the artefact is deterministic: build it, test it, ship it, and the behaviour that passed testing is the behaviour users receive. An LLM application breaks that assumption twice. The artefact includes prompts and configurations whose effect depends on a model that can change underneath you, and the behaviour itself is stochastic, so "it passed the tests" means "it passed with acceptable probability", not "it is correct".

Those two facts reshape the pipeline rather than replacing it. Linting, unit tests, and build steps remain. What is added is a quality-gate stage that scores model-in-the-loop behaviour against a stored baseline, a versioning scheme that binds prompts, model identifiers, and evaluation sets into one releasable unit, and a rollout strategy that treats every production change as an experiment with a rollback trigger attached. What is removed is any reliance on a single green run as proof: for non-deterministic services, proof is a distribution of results compared against a known-good distribution.

Cost awareness is a third difference. Running a full evaluation suite against a frontier model on every push is metered work; a pipeline that does this will either be slow or will be quietly disabled under delivery pressure. Budgeting evaluation the way you budget test infrastructure — free checks everywhere, metered checks on relevant changes — is what keeps the pipeline in use.

The pipeline, stage by stage

The shape most teams converge on: a commit triggers linting and formatting, then the free deterministic suite (prompt rendering, budgets, schemas, mocked integration tests), then a change classifier that decides whether model-in-the-loop evaluation is required at all. If prompts, models, or retrieval configuration changed, the scored evaluation runs against a reduced set with a comparison to the stored baseline. A passing gate allows merge; merging to the main branch triggers a canary deployment; the canary runs for a defined observation window against live metrics; promotion or automatic rollback closes the loop.

name: llm-app-ci
on:
  pull_request:
    paths: ["prompts/**", "src/**", "evals/**"]
  push:
    branches: [main]

jobs:
  deterministic:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Lint and typecheck
        run: make lint
      - name: Prompt and mock tests
        run: pytest tests/unit tests/integration -q

  scored-eval:
    needs: deterministic
    if: contains(github.event.pull_request.labels.*.name, 'model-change')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run evaluation subset against baseline
        env:
          EVAL_BUDGET_USD: "25"
        run: python evals/run.py --subset reduced --compare-baseline --fail-on-regress

  canary:
    needs: scored-eval
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - name: Deploy 5 percent canary
        run: python deploy/canary.py --traffic 5 --window 24h

The change classifier matters as much as the stages. Labelling a pull request as a model change, or detecting one by diffing the prompt and configuration directories, keeps the metered stage off documentation edits while still catching every change that can move behaviour.

Versioning prompts, configs and eval sets together

The release unit for an LLM application is not the code commit alone. It is the code plus the prompt versions plus the model identifier and parameters plus the evaluation-set version used to approve it. Bind them with a release manifest: a small file listing each artefact and its content hash, written at build time and recorded at deploy time. With that manifest, any production response can be traced to the exact configuration that produced it, and any regression can be reproduced offline by checking out the same manifest.

Prompts themselves follow the same rules as code: immutable versions, an explicit promotion pointer, and no in-place edits. A deploy that changes behaviour without changing a version identifier is a deploy you cannot explain during an incident.

Quality gates and their thresholds

A quality gate is a set of scored checks with numeric thresholds and a comparison policy. Absolute thresholds ("faithfulness must exceed 0.85") are useful as floors; regression comparisons ("no metric may drop more than two points against the current production baseline") are what actually protect users, because they are sensitive to changes in your specific system rather than to an abstract ideal.

Gates should also include cost and latency: if a prompt change raises median cost per request by forty percent, that is a release-quality fact, not an operational footnote. And gates must fail loudly with actionable messages — which metric moved, by how much, on which cases, and where the report lives. A gate whose output is a red cross with no explanation gets overridden on the first busy Friday.

GateComparisonThresholdBlocks
Prompt renderingDeterministicZero failuresAlways
Format validityDeterministic100 percentAlways
FaithfulnessBaselineNo drop beyond 0.02Model changes
Answer relevanceBaselineNo drop beyond 0.02Model changes
p95 latencyAbsolute and baselineNo increase beyond 15 percentModel changes
Cost per requestBaselineNo increase beyond 10 percentModel changes

Canary rollouts for non-deterministic services

A canary for an LLM service is an experiment, not just a deployment. Route a small slice of traffic — five percent is a common start — to the new version, tagged in logs so its metrics can be compared against the incumbent running in parallel. The observation window must be long enough for the metrics you care about to stabilise: latency and error rate within an hour, user feedback and judged quality over a day or more.

Promotion criteria should be numeric and pre-registered: no regression in the primary quality metric, no increase in refusal or error rate beyond agreed bounds, and cost within budget. Because both versions run simultaneously, the comparison is a proper controlled experiment rather than a before-and-after guess confounded by traffic mix.

Rollback: the only deploy feature that matters

Automated rollback is what makes the rest of the pipeline safe to iterate on. Wire the canary's live metrics to a rollback trigger: sustained error-rate increase, feedback-rate collapse, or a judged-quality sample below the floor. Rollback must be a pointer change, not a rebuild — which means the previous release manifest and its prompt versions remain deployable at all times. Test the rollback path on a schedule, the same way you test restore procedures for a database; an untested rollback is a hypothesis.

python
import hashlib
from dataclasses import dataclass, field
from datetime import datetime


@dataclass
class Canary:
    name: str
    manifest: str
    traffic_percent: float = 5.0
    status: str = "active"
    started_at: str = field(default_factory=lambda: datetime.utcnow().isoformat())


class CanaryRouter:
    def __init__(self, incumbent_manifest: str):
        self.incumbent = incumbent_manifest
        self.canaries: list[Canary] = []

    def deploy(self, canary: Canary) -> None:
        self.canaries.append(canary)

    def variant_for(self, subject_id: str) -> tuple[str, str]:
        for canary in self.canaries:
            if canary.status != "active":
                continue
            bucket = int(hashlib.sha256(subject_id.encode()).hexdigest()[:8], 16) % 100
            if bucket < int(canary.traffic_percent):
                return ("canary", canary.manifest)
        return ("incumbent", self.incumbent)

    def rollback(self, name: str) -> None:
        for canary in self.canaries:
            if canary.name == name:
                canary.status = "rolled_back"
                canary.traffic_percent = 0.0

    def promote(self, name: str, to_percent: float = 100.0) -> None:
        for canary in self.canaries:
            if canary.name == name:
                canary.traffic_percent = to_percent
                if to_percent >= 100.0:
                    canary.status = "promoted"

Hash-based assignment matters: it keeps a single user on one version for the duration of the experiment, so feedback and conversion events are attributed to the variant that actually produced them.

Keep human override available in both directions. An operator should be able to halt a promotion that automated checks have not yet caught, and to approve one that failed a gate for a known and documented reason. Both actions are logged with the operator's identity and rationale, because they are the highest-leverage edits to your release history.

Cost and time budgets for the pipeline itself

Track the pipeline's own bill. Evaluation runs against frontier models can quietly become the largest line item in a development environment. Cap spend per run, cache judge results by content hash, prefer mid-tier models for the reduced subset where they correlate with the full set, and shrink the default suite to the cases with the highest historical defect yield. A pipeline that costs more than the incidents it prevents will be bypassed, and a bypassed pipeline protects nothing.

Best Practices

  • Classify changes so metered evaluation runs only when prompts, models, or retrieval configuration actually change.
  • Bind code, prompt versions, model identifiers, and eval-set versions in a hashed release manifest recorded at deploy time.
  • Gate releases on regression deltas against the production baseline, with cost and latency as first-class gate metrics.
  • Run canaries as controlled experiments with pre-registered numeric promotion criteria and a full observation window.
  • Make rollback a pointer change to a previously validated manifest, and test the rollback path on a schedule.
  • Cap evaluation spend per run and cache judge outputs so the pipeline stays cheap enough to keep enabled.

Key Takeaways

  • Non-deterministic services need distributional proof: compare a scored evaluation run against a stored baseline, not a single green build.
  • The releasable unit is code plus prompts plus model config plus eval-set version, bound in a hashed manifest.
  • Quality gates protect users best as regression comparisons, with absolute scores serving as secondary floors.
  • Canaries turn deploys into controlled experiments; promotion criteria must be numeric and decided before the window opens.
  • Automated rollback with an always-deployable previous manifest is the safety property that enables fast iteration.
  • Budget the pipeline's own evaluation spend or delivery pressure will disable it.
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-13

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert AI Ops & LLM Ops Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement