Skip to main content
Shadow Testing and Canary Releases for LLM Changes

Shadow Testing and Canary Releases for LLM Changes

KU
· Founder & Chief Editor
• 8 min read•Updated •52 views

A prompt tweak or model bump can quietly wreck answers everywhere. Ship LLM changes the way you ship risky code: gate, shadow, canary, roll back.

Key takeaways

  • Treat every prompt, model or retrieval change as a risky deploy.
  • Block the merge with an offline golden-set eval, run the candidate in shadow on live traffic while users still get the current version, then canary it to 1 percent with deterministic per-user routing and automatic rollback on quality, latency, error or cost breaches.

Ship LLM changes in three gates: an offline golden-set eval in CI that blocks regressions, a shadow run where the candidate answers live traffic but only the current version is served, and a 1 percent canary with deterministic per-user routing and automatic rollback on quality, latency, error-rate or cost breaches. Version every prompt and model.

Verified against

Claude API model IDs (current lineup, including claude-sonnet-5-5), against Anthropic's models overview, the Google SRE Workbook chapter on canarying releases, and the Argo Rollouts canary docs. Checked October 2026.

The scariest deploys in an LLM product are rarely schema migrations. They are two-word prompt edits. Someone swaps "be concise" for "be brief and direct," merges it on a Friday, and by Monday a business metric like support deflection has slipped. No error, no alert, no stack trace. The model just started answering slightly worse for everyone at once.

That's what makes LLM changes different. A model version bump, a prompt reword, a retriever swap, a chunking tweak, a temperature change: each one rewrites the behavior of every request simultaneously. There's no partial failure to catch your eye. Quality erosion looks exactly like normal traffic until someone reads the transcripts. So we stopped treating these as config edits and started treating them like risky code: gated, observed, and reversible.

Gate offline before anything touches traffic

The first line of defense is a golden-set eval that runs in CI and blocks the merge. We keep a versioned set of a few hundred real queries with reference answers and expected retrieved docs. Every prompt or model change runs against it, and the job fails if any tracked metric regresses past a threshold.

Python
# eval_gate.py: runs in CI, exit non-zero to block merge
import json, sys
from evals import run_suite, load_golden

BASELINE = json.load(open("evals/baseline_scores.json"))
THRESHOLDS = {"faithfulness": -0.02, "answer_quality": -0.03, "cost_usd": 0.15}

def main(candidate_cfg):
    scores = run_suite(load_golden("evals/golden_v7.jsonl"), candidate_cfg)
    failed = []
    for metric, floor in THRESHOLDS.items():
        delta = scores[metric] - BASELINE[metric]
        # cost floor is a max increase; quality floors are max drops
        regressed = delta > floor if metric == "cost_usd" else delta < floor
        if regressed:
            failed.append(f"{metric}: {BASELINE[metric]:.3f} -> {scores[metric]:.3f}")
    if failed:
        print("EVAL GATE FAILED\n" + "\n".join(failed)); sys.exit(1)
    print("eval gate passed"); json.dump(scores, open("evals/candidate_scores.json","w"))

if __name__ == "__main__":
    main(sys.argv[1])

The gate catches obvious regressions cheaply; building the golden set itself is covered in our offline retrieval evaluation harness. What it can't catch is the long tail of real traffic your golden set never imagined. That's what shadow mode is for.

Shadow mode: run the new version, serve the old one

Once a change clears the gate, we deploy it in shadow. Both versions run on every live request. Production still serves the current version to the user. The candidate runs in the background, its output logged and never returned. Then we compare.

Python
# shadow.py
async def handle(request):
    prod = await llm_answer(request, cfg=PROD_CFG)
    # fire-and-forget the shadow so it never blocks the user path
    asyncio.create_task(shadow_compare(request, prod))
    return prod  # user only ever sees prod

async def shadow_compare(request, prod):
    try:
        shadow = await llm_answer(request, cfg=CANDIDATE_CFG)
        await metrics.emit({
            "req_id": request.id,
            "prod_faithfulness": await judge_faithful(prod, request.context),
            "shadow_faithfulness": await judge_faithful(shadow, request.context),
            "agreement": semantic_sim(prod.text, shadow.text),
            "prod_cost": prod.cost_usd, "shadow_cost": shadow.cost_usd,
            "prod_latency_ms": prod.latency_ms, "shadow_latency_ms": shadow.latency_ms,
        })
    except Exception as e:
        metrics.count("shadow_error", tags={"kind": type(e).__name__})

Shadow answers three questions before a single user is exposed. Where does the new version disagree with prod, and are those disagreements improvements or regressions when a judge scores them side by side? What does it cost and how slow is it on the real query distribution, not the tidy golden set? And how often does it error or time out on inputs the eval never covered? We let shadow soak for a few days so it sees weekday and weekend traffic. If agreement is high and the disagreements skew better, we promote to canary. This is the same discipline behind retrieval-augmented generation that holds up in production.

Canary: serve it to a sliver, watch, auto-roll-back

Canary routes a small slice of real traffic to the new version and actually serves it. We start at 1 percent, hold, then step to 5, 25, 50, 100 as the signals stay clean. Routing is deterministic per user so nobody flip-flops between versions mid-session. The shape is the same one Argo Rollouts canary analysis automates for services; here the analysis metrics are about answer quality.

Python
# canary.py
def pick_version(user_id: str, canary_pct: int) -> str:
    bucket = int(hashlib.sha256(user_id.encode()).hexdigest(), 16) % 100
    return "candidate" if bucket < canary_pct else "prod"

# rollback watcher, runs every 60s against the canary cohort
def check_canary(window):
    c, base = window["candidate"], window["prod"]
    breaches = [
        c["faithfulness"] < base["faithfulness"] - 0.03,
        c["thumbs_down_rate"] > base["thumbs_down_rate"] * 1.25,
        c["p95_latency_ms"] > base["p95_latency_ms"] * 1.3,
        c["error_rate"] > base["error_rate"] + 0.005,
        c["cost_per_req"] > base["cost_per_req"] * 1.2,
    ]
    if any(breaches) and c["n"] > 200:  # wait for a real sample
        set_canary_pct(0)
        page("canary auto-rolled-back", detail=breaches)

The rollback is automatic and it defaults to zero. A human decides to ramp up; a threshold breach decides to ramp down. That asymmetry matters, because at 3am you want the safe direction to be the one that needs no one awake. Compare the canary cohort against the control cohort over the same window, never against last week: Google's SRE Workbook points out that an aggregate rate can hide a badly failing canary, and before/after comparisons pick up weekday and weekend noise.

What we actually measure

Offline scores lie a little, so the canary leans on live signals too. Faithfulness and answer quality come from an LLM judge scoring against retrieved context. User signals carry the real weight: thumbs, whether the user edited or retried the answer, and deflection or escalation rate for support flows. Then the boring operational trio: cost per request, p95 latency, and error rate. A change that lifts quality 2 percent while doubling cost is not a win, and the canary is where that trade-off shows its real number.

Version everything, name everything

None of this works if you can't say what shipped. Every prompt is a file in git with a semantic version, and the deployed config pins exact strings:

YAML
# config/answer.v7.yaml
prompt_id: answer_synthesis
prompt_version: 7.2.0
model: claude-sonnet-5-5
temperature: 0.2
retriever: hybrid_v3
golden_set: golden_v7

As of October 2026, Anthropic's docs describe every Claude model ID as a pinned snapshot, including the dateless IDs used from the 4.6 generation on, so claude-sonnet-5-5 won't drift underneath you. Moving to a new model is still a new ID and goes through the whole pipeline. The version string rides along in every logged request. When a metric moves, we can join it to the exact prompt and model that produced it instead of guessing which of last week's four merges did the damage.

The runbook, condensed

  1. Change the prompt or model config, bump the version, open the PR.
  2. CI runs the eval gate on the golden set; regression blocks the merge.
  3. Merge deploys to shadow; soak two to four days across a full traffic cycle.
  4. Review shadow: agreement, judge deltas, cost, latency, error rate.
  5. Promote to canary at 1 percent; the rollback watcher arms automatically.
  6. Ramp 1 to 5 to 25 to 50 to 100 as signals hold; any breach zeroes it out.
  7. Old version stays deployable for a week in case a slow signal surfaces late.

Questions people ask

What is shadow testing for LLMs?

Shadow testing runs a candidate prompt, model or retriever on the same live requests as production, but only the production answer is returned to the user. The candidate's output is logged and scored, usually by an LLM judge plus cost, latency and error metrics. It reveals how the change behaves on the real query distribution, including inputs your golden set never covered, without exposing a single user to it.

How big should an LLM canary be?

Start small, around 1 percent of users, routed deterministically by hashing the user ID so each person stays on one version. Hold until the canary cohort has enough requests for the comparison to mean something, then step to 5, 25, 50 and 100 percent. Google's SRE Workbook frames the trade-off: smaller canaries spend less error budget, but they must be large and long enough to be representative.

What should trigger an automatic rollback?

Compare canary against control over the same window and roll back on any breach: judge-scored faithfulness dropping past a margin, thumbs-down rate rising, p95 latency or error rate climbing, or cost per request jumping. Require a minimum sample before acting so noise doesn't flap the canary. Rollback should set traffic to zero automatically; ramping up should always need a human.

The call we'd make

If you only build one of these, build the eval gate: it's cheap and catches the dumb regressions before they ever ship. But the gate alone will lull you, because the failures that actually hurt live in traffic your golden set never saw. Shadow plus a small auto-rollback canary is what turns "we think this is better" into "we watched it be better on real users and nothing broke." That's a slower way to ship a prompt edit. After a Friday incident like the one above, slower is exactly what you want.

Sources

Explore topics:LLMAI
React
Share this post
Cite this article
Plain text

Kiril Urbonas (2026). Shadow Testing and Canary Releases for LLM Changes. DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/shadow-testing-and-canary-releases-for-llm-changes

Markdown

[Shadow Testing and Canary Releases for LLM Changes](https://www.devopsness.com/blog/shadow-testing-and-canary-releases-for-llm-changes) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)

KU

Kiril Urbonas

Founder & Chief Editor

586 articles
View all articles by Kiril Urbonas

You might have missed

Evergreen posts worth revisiting.