All posts

How to roll out an LLM prompt or model change safely: shadow mode, canary and A/B testing

How to roll out an LLM prompt or model change without surprising users: shadow mode, canary releases and A/B tests, what each answers, what each costs, and the gates between them.

CodeKrypt 6 min read

A new model version tops the benchmarks, or someone rewrites the system prompt to fix a complaint. The offline evals pass. You ship to everyone, and a week later a customer-facing behaviour you never tested has shifted. The fix is not more offline testing; it is a better LLM prompt rollout: a staged release where real traffic, not just your test set, decides whether a change goes wide.

This post covers the domain, not any particular deployment of ours. The sources are public practitioner and vendor write-ups, linked inline; most are blogs or product docs rather than peer-reviewed work, so read specific thresholds as illustrative.

Why aren't offline evals enough for an LLM change?

Offline evals run on a dataset you chose in advance. Production traffic is messier, and LLM outputs are non-deterministic. Our earlier post on LLM evals in CI covers the pre-merge gate, and it should stay. But an eval set can miss real-world inputs, latency effects and differences in how tools get called. Staged release exists to catch what the eval set could not predict, with a small blast radius while it does.

What do shadow mode, canary and A/B testing each answer?

They are three different questions, which is why they are often chained rather than chosen between.

StageWhat happensQuestion it answersUsers affected?Main cost
Shadow modeNew version runs in the background on real inputs; outputs are compared, not shownDoes it behave sensibly on real traffic?NoYou pay for both versions on shadowed requests
CanaryA small share of live requests goes to the new versionIs it safe to serve?Yes, a small shareNeeds routing, monitoring and fast rollback
A/B testTraffic is split between versions and a metric is comparedIs it actually better?YesMore traffic and time to reach a clear result

One practitioner write-up frames it well: a canary tells you whether the new version is safe to deploy, while an A/B test tells you whether it is better (tianpan.co). Safe and better are separate claims, and many teams only ever test the first.

Staged rollout path: offline evals, shadow mode, canary, A/B test, full release, with a rollback arrowOffline evalsShadowCanaryA/B testFull releaseA gate between each stage; any failure returns to the previous version

How does shadow mode work, and what does it cost?

In shadow mode the old version still answers the user. The new version receives the same input in the background and its output is logged and scored, never shown. One practitioner post describes it as the safest way to evaluate a prompt change (shadow mode for LLM changes).

The catch is spend: you pay for both versions on every shadowed request, so shadow runs are usually a sample over a limited window. Run the shadow call asynchronously so it cannot add latency or fail the user's request. This is also why LLM cost control and rollout planning belong in the same conversation.

Shadow mode has a blind spot. Because users never see the output, it cannot tell you how people react, and it can miss production effects such as latency or tool-call differences. That is what the canary is for.

How do you run a canary release for an LLM change?

Route a small share of live requests to the new version while the stable version serves the rest, and watch metrics you defined beforehand. The PromptLayer glossary describes the idea as limiting exposure by routing only a percentage of live requests to the new prompt. Practical points:

How do you A/B test an LLM change properly?

Use an A/B test when the question is "is it better", for example a different tone, a new retrieval setup or a cheaper model you hope is no worse. Two LLM-specific cautions. First, non-determinism adds variance, and one source estimates you often need three to five times more users for the same statistical power (tianpan.co); treat that multiplier as a rough rule of thumb. Second, pick the metric before you look at results, and prefer outcome metrics over style ratings.

Tooling exists for this. Datadog's prompt experimentation supports A/B tests and guarded rollouts, and choosing a winner there does not deploy it automatically; you conclude the test, then deploy your chosen version yourself. That separation is a good habit regardless of tool.

Do you need all three for every change?

Sources disagree. One argues shadow mode suits major changes such as model upgrades or restructured prompts, not small tweaks; another argues even same-model prompt edits deserve the full path, because the edit you assume is harmless is exactly what process catches. Our reading: scale the process to the blast radius.

ChangeSuggested path
Typo or formatting fix in a low-stakes promptOffline evals, then release with fast rollback
Behaviour-changing prompt editOffline evals, short canary
Model upgrade or provider swapOffline evals, shadow, canary; see model deprecation planning
Agent with tools that take real actionsAll stages, plus approval gates
Claimed improvement you want to proveA/B test with a pre-chosen metric

What infrastructure does a gradual rollout need?

All three stages share one requirement: the ability to route requests between versions dynamically, without a code deploy. In practice that means:

  1. A version pointer (config flag or registry tag) per prompt and model.
  2. A router that assigns traffic by percentage and sticks per user.
  3. Version IDs on every trace and log line.
  4. Dashboards that compare versions side by side.
  5. A rollback you have actually timed, ideally one action.

If you are on a single provider, add a fallback path at the same layer; the router is the natural place for both.

What to do next

  1. Write down how a prompt or model change reaches production today. If the answer is "merge and deploy", you have no staged release.
  2. Add a version ID to every LLM call log.
  3. Make the live version a pointer you can change without a deploy.
  4. Define rollback triggers for your most important flow before the next change.
  5. Start with a canary; add shadow mode for model swaps and A/B tests when you need to prove an improvement.

If you are building an AI product and want staged releases, evals and rollback designed in from the start, that is the kind of work our AI SaaS service covers.

Sources

CodeKrypt avatar

CodeKrypt

Drafted by CodeKrypt's AI writing pipeline, built and maintained by our engineers, under fixed rules on sources and claims. How we write

Frequently asked questions

What is the difference between shadow mode, a canary and an A/B test for LLMs?
Shadow mode runs the new version in the background on real inputs and compares outputs without users seeing them. A canary serves the new version to a small share of live users to check it is safe. An A/B test splits traffic to check whether the new version is actually better on a metric you care about.
Do I need shadow mode for a small prompt tweak?
Sources disagree. Some reserve shadow mode for major changes such as model upgrades or restructured prompts; others argue that even small prompt edits should follow the same path. A reasonable middle: scale the process to the blast radius, and always keep an offline eval gate and a fast rollback.
What does shadow mode cost?
You pay for both versions on every shadowed request, so LLM spend for that traffic roughly doubles while it runs. Teams usually shadow a sample of traffic for a limited time rather than everything.
What do I need before I can do a gradual rollout?
A way to route requests between versions without a code deploy, a version identifier logged on every call, metrics you can slice by version, and a rollback you have timed.

Related reading

Chat on WhatsApp