← All articles

Practical guide · · By Raz Dagan

How to define canary and rollback signals for an LLM-to-code replacement

Choose coverage, disagreement, fallback and operational thresholds before a generated replacement reaches production traffic.

A rollout needs two decisions, not one score

A held-out evaluation answers whether a candidate is ready to test. It does not decide how much live traffic the candidate should receive or when the team should reverse the rollout. Write separate entry criteria for the canary and rollback criteria for production.

For a deterministic replacement, useful signals include eligible-input coverage, comparator disagreement, explicit fallback rate, error rate and latency. Keep business outcomes separate where attribution is slow or noisy. A single aggregate pass rate can hide a failure concentrated in one input class.

Define the eligible population first

State which requests the replacement is allowed to handle. Eligibility may depend on a schema version, a known operation, required fields or an application feature flag. Everything else should remain on the existing path rather than being coerced into the new function.

Measure coverage as eligible requests divided by all requests for the task, then measure successful deterministic handling within that eligible group. This prevents a narrow replacement from appearing complete because it performs well on the easiest five percent.

Compare without duplicating side effects

During shadow evaluation, run the candidate only on the transformation that can be repeated safely. Do not send a second email, create a second ticket or write a duplicate record merely to compare outputs. Capture the input and compare the candidate result before the application performs the action once.

If the original workflow reads mutable state, record which snapshot or version each path used. A disagreement caused by different state freshness is not evidence that either implementation is wrong until the inputs are aligned.

Set rollback signals before traffic starts

Choose thresholds the team can observe quickly: unexpected exceptions, invalid outputs, fallback spikes, comparator mismatches and downstream rejection. Define the time window and minimum sample size so one rare event does not trigger an unexplained toggle while a sustained issue cannot be ignored.

Include hard-stop conditions for high-consequence errors even when the sample is small. Document who can disable the replacement, where the flag lives and what evidence must be preserved for review. Rollback should restore the previous path without requiring a new code generation run.

Expand the canary by evidence

Start with a small eligible cohort, verify the signals and then increase exposure in deliberate steps. Compare each step with the baseline distribution, not only the immediately previous step. A stable 10 percent canary does not prove that long-tail inputs at full traffic are safe.

Keep fallback available during the rollout and count every call it makes. Provider cost avoided must be calculated after fallback traffic, monitoring and maintenance. Do not report projected savings as measured savings.

Use ModelGate as part of the application release

ModelGate evaluates generated code against held-out examples and delivers code for review. The generated replacement runs inside the customer's application; ModelGate does not execute the supplied Python port. The application remains responsible for feature flags, state access, side effects and production rollback.

Store the comparator, eligibility rule and rollback plan next to the pull request. Review disagreements before merge, run the application tests and verify the code on real held-out examples. A successful canary is evidence for expansion, not a guarantee that every future input will match.

Explore the workflow

Read the code-replacement requirements, GitHub workflow and gateway comparison before deciding.