Skip to main content
Back to all articles
AI Engineering 12 min readUpdated September 15, 2026

Changing the Model ID Is a Production Migration: Build an Eval Gate Before You Upgrade

Treat LLM model upgrades as production migrations: compare a known-good baseline with the candidate, gate regressions, canary safely, and preserve fast rollback.

By Salman Butt · Senior Full-Stack & Generative AI Engineer
#LLM Evals#Model Migration#Generative AI#TypeScript#LLM Reliability#Production AI
On this page

A one-line diff changes the model identifier.

TypeScript
const MODEL = "new-model";

CI stays green. The TypeScript types are unchanged. The provider still returns HTTP 200. A few staging prompts even look better, so the release ships.

Then the failures arrive in places the API contract never described.

A support workflow chooses a tool more aggressively than before. A JSON response is syntactically valid but violates a business invariant. A retrieval answer sounds cleaner while dropping the citation that made it auditable. A safety-sensitive flow refuses legitimate requests more often. Median latency improves, but the long tail gets worse enough to trip an upstream timeout.

Nothing in the compiler told you the release was unsafe.

That is because an LLM upgrade is not just a dependency bump. It is a behavioral migration.

The practical consequence is simple: do not promote a new model because it is newer, cheaper, faster, or better on a public benchmark. Promote it because the complete versioned AI runtime satisfies the behavior contract your application actually depends on.

The mechanism that enforces that decision is an eval gate.

The API contract did not break. The behavior contract did.

Traditional application migrations usually expose themselves through an interface we can test directly. A database column changes. An endpoint disappears. A function signature stops compiling. A schema validator rejects the payload.

Model upgrades are harder because the external API can remain compatible while the semantics change.

For a production LLM application, the real contract may include questions such as:

BehaviorWhat must remain true?Failure consequence
Tool useSelect the correct tool, or no tool, with valid argumentsWrong side effect
Structured outputSatisfy schema and business invariantsParser failure or corrupted workflow state
RetrievalMake claims supported by supplied evidenceConfident but unsupported answer
SafetyRefuse disallowed requests without blocking valid workUnsafe behavior or over-refusal
Agent controlStop, continue, escalate, and retry at the correct boundaryLoops, duplicate work, or lost progress
OperationsStay inside latency and cost budgetsSLO breach or unexpected spend

A provider may describe a replacement as compatible at the API level. That still does not prove compatibility with your prompts, tools, retrieval strategy, output validators, or user distribution.

Anthropic's own model lifecycle guidance, for example, explicitly recommends thoroughly testing applications with replacement models before retirement deadlines. OpenAI's evaluation guidance similarly treats evals as the mechanism for measuring application behavior as models, prompts, and other components change.

The application owns the behavior contract.

Write the behavior contract before choosing the candidate

A weak migration process starts with the candidate model and asks:

Does this look better?

A stronger process starts with the production system and asks:

What observable behavior are we unwilling to regress?

That difference matters because a single "quality" score can hide the failure you care about most.

Suppose a candidate improves general-answer quality from 92% to 96%, but tool authorization accuracy drops from 99.7% to 98.5%. An aggregate score may still improve. A transactional agent may still become less safe.

Define separate dimensions instead.

For a RAG assistant, I might care about:

  • groundedness against retrieved evidence;
  • citation correctness;
  • abstaining when evidence is insufficient;
  • structured-answer validity;
  • latency and token usage.

For an agent that can change external state, I would add:

  • correct tool selection;
  • correct no-tool decisions;
  • argument validity;
  • permission-boundary adherence;
  • duplicate-side-effect prevention;
  • escalation behavior.

Those are not generic model metrics. They are application requirements.

Your eval set is the migration test suite

Once the behavior contract is clear, build an eval set that represents the workload you are actually migrating.

The strongest datasets usually combine several sources:

  1. Representative production traces after appropriate privacy filtering and redaction.
  2. Historical failures that already taught you something expensive.
  3. Boundary cases where tool choice, refusal, or routing is ambiguous.
  4. Long-context and retrieval cases that stress context assembly.
  5. No-action cases where the correct behavior is to avoid a tool call.
  6. Adversarial or safety cases for workflows where untrusted input can influence execution.

Do not turn the dataset into a static museum. Version it.

TypeScript
type EvalDataset = {  version: string;  cases: EvalCase[];};

If a production incident reveals a missing behavior, add a regression case. If users start using the product differently, refresh the distribution. If a tool schema changes, update or split the relevant segment.

An eval suite that never changes eventually becomes a test for yesterday's product.

Grade the contract, not the prose

Exact-string matching is useful when the output itself is deterministic. It is usually a poor evaluator for open-ended language.

If the requirement is "the answer must cite the supplied invoice and must not invent a due date," grade those properties directly. Do not fail the candidate because it used different wording from a golden paragraph.

Prefer deterministic checks where the requirement is deterministic:

  • JSON Schema validation;
  • enum membership;
  • required field presence;
  • numerical bounds;
  • tool name and argument checks;
  • authorization rules;
  • citation identifiers;
  • forbidden-side-effect detection.

Use model-based graders for semantic properties that genuinely require judgment, such as relevance or evidence support. Those graders should still be calibrated against human review, because the evaluator is another model with its own failure modes.

Compare candidate and baseline on the same workload

A migration gate needs a known-good baseline.

Testing only the candidate tells you whether it reaches some absolute score. It does not tell you what changed.

If the candidate scores 96%, that sounds strong until you learn that the current production model scores 99% on the same critical segment.

Run both releases against the same dataset and the same evaluation logic.

TypeScript
type SegmentMetrics = {  passRate: number;  p95LatencyMs: number;  averageCostUsd?: number;};​type EvalGate = {  minimumPassRate: number;  maxRegression: number;};​function assertEvalGate(  baseline: SegmentMetrics,  candidate: SegmentMetrics,  gate: EvalGate,): void {  if (candidate.passRate < gate.minimumPassRate) {    throw new Error(      `Candidate pass rate ${candidate.passRate} is below floor ${gate.minimumPassRate}`,    );  }​  const regression = baseline.passRate - candidate.passRate;​  if (regression > gate.maxRegression) {    throw new Error(      `Candidate regressed by ${regression}; budget is ${gate.maxRegression}`,    );  }}

The threshold values belong to the application, not to a blog post. A low-risk summarizer and an agent that can issue refunds should not share the same release policy.

I prefer using both:

  • an absolute floor, so a weak baseline cannot justify a weak candidate;
  • a regression budget, so a candidate cannot silently trade away an important behavior.

Apply those gates per segment. An overall average is useful for reporting, but it should not be able to hide a critical safety or tool-use regression.

For stochastic tasks, one run may also be misleading. Repeated trials can reveal variance that a single sample misses, especially on borderline routing or tool-selection decisions.

The model is not the real deployment unit

There is another migration mistake that makes debugging unnecessarily difficult: changing the model together with several other AI-runtime components and recording only the model name.

A production response is a function of much more than the model.

It may depend on:

  • system instructions;
  • tool schemas and descriptions;
  • retrieval settings;
  • context ordering;
  • memory policy;
  • provider parameters;
  • grader logic;
  • routing rules.

I would version those pieces together as an explicit release manifest.

TypeScript
type LLMRelease = {  id: string;  model: string;  systemPromptVersion: string;  toolSchemaVersion: string;  retrievalConfigVersion: string;  evalSetVersion: string;  graderVersion: string;};​const candidateRelease: LLMRelease = {  id: "support-agent-2026-09-08.1",  model: "candidate-model",  systemPromptVersion: "prompt-v17",  toolSchemaVersion: "tools-v8",  retrievalConfigVersion: "retrieval-v5",  evalSetVersion: "support-evals-v12",  graderVersion: "graders-v6",};

This turns "we upgraded the model" into something reproducible.

If the candidate fails, you can identify exactly what was evaluated. If you need to roll back, you can restore the previous release manifest rather than guessing which prompt, tool schema, or retrieval configuration was paired with the previous model.

Version the graders as well. Changing the evaluator can move your score even when the application behavior did not change.

Put the eval gate in the release path

An eval dashboard is useful. An eval gate is stronger because it can block promotion.

A minimal release path looks like this:

Text
candidate release      |      voffline baseline/candidate eval      |      vpolicy gate      |      +---- fail ----> block release      |      vshadow traffic      |      vsticky canary cohort      |      vstaged rollout      |      vfull release​rollback ---------> previous versioned release

Each stage answers a different question.

Offline evaluation

Can the candidate satisfy the known behavior contract on controlled cases?

This is where you get reproducibility and fast comparisons.

Shadow traffic

How does the candidate behave on current production-shaped inputs without controlling the user-facing result?

Shadowing is powerful, but it becomes dangerous when the model can trigger side effects. A shadow agent must not send a second email, create a duplicate ticket, charge a card, or write to the same mutable system simply because you wanted a comparison.

Use read-only tools, mocks, sandboxes, or an execution layer that records intended actions without committing them.

Canary rollout

How does the candidate behave when it actually serves a small fraction of real traffic?

For conversational and stateful systems, make assignment sticky. If a user alternates randomly between the baseline and candidate on every turn, you create mixed histories that make both behavior and diagnosis harder to interpret.

Assign by a stable key such as account, workspace, session, or user, depending on the product's data model.

Staged promotion

Increase exposure only while both quality and operational metrics stay inside policy.

The same release identifier should appear in traces, logs, eval results, and business metrics so that a regression can be tied to the exact runtime configuration that produced it.

Offline evals tell you what you tested, not what users will do

A candidate can pass every offline gate and still fail in production.

The eval dataset is finite. Production is not.

Users will produce:

  • combinations you did not anticipate;
  • longer conversations;
  • different languages;
  • malformed attachments;
  • unusual tool sequences;
  • changing external data;
  • adversarial input;
  • traffic spikes and rate-limit pressure.

That is why the migration needs online observability after the gate.

Useful release-level metrics may include:

  • structured-output validation rate;
  • tool-call error rate;
  • task completion rate;
  • groundedness or citation failures;
  • fallback and human-escalation rate;
  • refusal and over-refusal rate;
  • retry count;
  • p50 and p95 latency;
  • prompt and completion token usage;
  • cost per successful task.

The exact metrics depend on the workflow. The important part is attaching them to the release version, not merely to the provider or model family.

A latency regression can be as real as a quality regression. A model that is slightly better but regularly exceeds an upstream 10-second timeout may be worse for the system.

The eval gate can lie

Adding evals does not automatically create a safe migration process. The evaluation system itself can fail.

The dataset can go stale

If the suite reflects last quarter's traffic while the product has moved into new workflows, the gate is guarding the wrong distribution.

The team can overfit to the benchmark

Repeated prompt changes against the same small eval set can optimize for those examples instead of the broader production task.

Keep holdout cases where practical and keep feeding real failures back into the suite.

Aggregate metrics can hide critical regressions

A 2% improvement in generic answers should not cancel a 1% drop in correct high-risk tool authorization.

Segment the gate by consequence.

The judge can drift

If an LLM-based evaluator changes, your score may change even if the application does not. Pin and version the grader configuration, and periodically compare it with human labels.

One stochastic run can create false confidence

Some behaviors have enough variance that a single run is not representative. Measure repeated outcomes where that uncertainty materially affects the decision.

Evaluation can accidentally execute real side effects

This is especially dangerous in agent systems. A migration suite that invokes the production payment, messaging, deletion, or provisioning tool is no longer just testing behavior.

Put a hard execution boundary around eval environments.

Quality can improve while economics regress

A candidate that passes semantic tests but doubles latency or cost may still violate the product's operational contract.

Treat quality, safety, latency, and cost as separate dimensions of the release decision.

Roll back the release, not just the model name

When production telemetry crosses a rollback threshold, the recovery path should be boring.

Do not start editing prompts under pressure. Do not swap only the model while leaving the candidate's new tool descriptions or retrieval settings active.

Point traffic back to the last known-good release manifest.

TypeScript
type ReleasePointer = {  activeReleaseId: string;};​async function rollback(  pointer: ReleasePointer,  previousReleaseId: string,): Promise<ReleasePointer> {  return {    ...pointer,    activeReleaseId: previousReleaseId,  };}

In a real system, that pointer may live in feature configuration, a deployment manifest, a routing service, or another strongly controlled source of truth. The implementation is less important than the property: the rollback restores the complete configuration that was actually evaluated.

This also makes incident analysis cleaner. You can preserve the failed candidate for replay while production returns to a known state.

The process should match the risk

An eval gate adds cost.

You need datasets, graders, repeated model calls, CI or release infrastructure, telemetry, and people who maintain the tests. Large suites can slow releases and consume meaningful inference budget.

That complexity is not equally valuable everywhere.

A low-risk internal copywriting helper may be fine with a small representative suite, manual review, and a lightweight canary.

A customer-support agent that can issue credits needs stronger tool-use and authorization evals.

An agent that can modify financial, legal, security, or infrastructure state deserves an even stricter release process, explicit execution guardrails, and rollback criteria.

The principle is not "build the largest eval platform possible."

It is:

Match the evidence required for promotion to the consequence of getting the behavior wrong.

The takeaway

The wrong migration question is:

Is the new model better?

The production question is:

Does this versioned runtime still satisfy our behavior contract, remain inside its regression budget, and give us a fast path to detect and reverse failures we did not predict?

A model identifier is only one field in that runtime.

Version the complete release. Compare candidate and baseline on the same application-specific eval set. Gate critical behaviors independently. Shadow without side effects. Canary with stable cohorts. Observe real traffic by release version. Roll back the whole bundle when the evidence says to stop.

That turns an LLM upgrade from a hopeful one-line change into a controlled production migration.

FAQ

If a provider calls a model a drop-in replacement, do I still need evals?

Yes for any production workflow whose behavior matters. API compatibility tells you the request can be accepted; it does not prove identical tool selection, formatting, grounding, refusals, latency, or task success in your application. Providers themselves recommend testing applications during model migrations.

How many eval cases do I need before upgrading?

There is no useful universal number. Coverage of important behaviors and failure boundaries matters more than an arbitrary dataset size. Start with representative traffic and known failures, then add boundary cases and regressions as the system evolves.

Can an LLM-as-a-judge be the only migration gate?

Usually not. Use deterministic validators for deterministic requirements such as schemas, permissions, tool arguments, and side-effect rules. Model-based graders are useful for semantic properties, but they should be calibrated and versioned rather than treated as an unquestionable oracle.

Do offline evals replace canary releases?

No. Offline evals measure the cases you collected. Canary releases expose the candidate to current production behavior and infrastructure conditions. Strong migrations use both because they protect against different classes of failure.

References

KEEP READING

Related engineering notes