LLMOps: releases, canaries and rollback

Version prompts, models and data together; gate releases with evals; deploy gradually; and handle model deprecations.

Expert about 5 h

The picture

  1. 01

    Change

    prompt, model, tool

  2. 02

    Eval gate

    CI

  3. 03

    Shadow

    compare silently

  4. 04

    Canary

    5% of traffic

  5. 05

    Promote or roll back

    metrics

What changes in an LLM system

Unlike ordinary code, behaviour changes when any of these change: the prompt, the model version (including silent provider updates), the retrieval index, the tool set, the decoding parameters, or the data. All of them need versioning and testing.

Version everything together

# prompts/ticket_triage/v7.yaml
id: ticket_triage
version: 7
model: claude-sonnet-5-5
params: { temperature: 0, max_tokens: 300 }
system: |
  You classify support tickets...
eval_set: evals/ticket_triage/golden_v3.jsonl
min_score: 0.92
import hashlib, yaml
def load_prompt(path):
    spec = yaml.safe_load(open(path))
    spec["hash"] = hashlib.sha256(open(path, "rb").read()).hexdigest()[:12]
    return spec

def log_request(trace, spec, index_version):
    trace.set_attribute("prompt.id", spec["id"]); trace.set_attribute("prompt.version", spec["version"])
    trace.set_attribute("prompt.hash", spec["hash"]); trace.set_attribute("index.version", index_version)

When quality changes, you can then say exactly what changed. Pin model versions (use dated or snapshot model identifiers where the provider offers them) so behaviour does not shift under you, and test new versions before moving.

A release pipeline

  1. Pull request: unit tests, lint, and the eval suite against the changed prompt or model; block on regressions (see eval-driven development).
  2. Staging: run against a copy of realistic traffic; check cost and latency.
  3. Shadow mode: the new version processes live requests but its output is not shown; compare to the current version offline.
  4. Canary: serve a small slice (1 to 5 percent) of real traffic; watch metrics.
  5. Promote gradually, or roll back automatically.
import hashlib

def bucket(user_id: str, salt="triage-v7") -> float:
    h = hashlib.sha256(f"{salt}:{user_id}".encode()).hexdigest()
    return int(h[:8], 16) / 0xFFFFFFFF            # stable in [0, 1]

def choose_version(user_id, canary_pct=0.05):
    return "v7" if bucket(user_id) < canary_pct else "v6"

Hashing the user id keeps each user on one version, which makes comparisons clean and avoids confusing flip-flopping.

Automatic rollback

Define guard metrics before launch and let the system act on them.

def should_rollback(canary, control, min_n=500):
    if canary.n < min_n:
        return False
    return (canary.error_rate > control.error_rate * 1.5
            or canary.p95_latency > control.p95_latency * 1.3
            or canary.cost_per_task > control.cost_per_task * 1.25
            or canary.thumbs_down_rate > control.thumbs_down_rate + 0.03)

Pair automatic guards with a manual kill switch (feature flag) that anyone on call can use without a deploy.

A gateway in front of models

A model gateway (LiteLLM or an internal service) centralises keys, routing, fallbacks to another model or provider on errors, rate limits, budgets, logging, and the redaction of sensitive data. It also means swapping a model is a configuration change.

Deprecations and drift

Providers retire models. Keep an inventory of which prompt uses which model, subscribe to deprecation notices, and keep an eval suite ready so that moving to the successor is a measured migration rather than a scramble. Run a small canary eval nightly against production models to catch silent behaviour drift.

Environment hygiene

  • Pin dependency versions; commit lockfiles.
  • Separate dev, staging and production keys, with spend caps.
  • Keep secrets in a secret manager, rotate them, and scan the repository for leaks.
  • Treat prompts, evals and policies as code: review, history, ownership.

Incident runbook

Write down, before you need it: how to see current error and cost rates, how to flip the kill switch, how to roll back, who is on call, how to communicate with users, and how to capture traces for the post-mortem. Practise it once.

Common mistakes

  • Editing a prompt in a dashboard with no history or tests.
  • Upgrading the model and the prompt in the same release.
  • A canary with too little traffic to detect a problem.

Exercises

  1. Move a prompt into a versioned file and wire an eval gate into CI that blocks a deliberately worse version.
  2. Implement hash-based canary routing and a rollback check, and simulate a regression to confirm it triggers.

You are done when you can…

  • Store prompts as versioned artefacts and record prompt, model and data versions on every request
  • Run a canary release with automatic rollback on metric regressions
  • Plan for a provider deprecating the model you depend on