Workflow recipe
Move an app to a new model without regressions
LLM model migration without surprises: freeze a golden set, run old and new models side by side, fix the prompts, compare cost, then roll out behind a flag.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
For an LLM model migration that does not break anything, find every call that uses the old model and its retirement date, freeze a golden set of real cases with checks, and run the old and new models side by side on it. Fix the prompts and request parameters for the new model until it matches or beats the old one, compare cost and latency on the same cases, then roll out behind a flag to a small share of traffic and keep the old model as a fallback until you are sure.
Model upgrades happen whether you want them or not. Providers retire models on a published timetable: on 25 November 2026, Anthropic’s deprecations page listed Claude Sonnet 4.5 for retirement on 30 November 2026 and Claude Opus 4.5 for 22 January 2027, and OpenAI keeps a similar deprecations list. After retirement, requests fail: on the Claude API, a call to a retired model returns a 404 not_found_error. Anthropic gives at least 60 days’ notice for publicly released models, which is enough time if you start when the email arrives and not enough if you start the week before.
The tempting shortcut is to change the model id, click around the app, and ship. A newer model is usually better overall and still different in ways that matter to you: it may format lists differently, write longer answers, call tools in a new order, refuse different things, or reject a request parameter the old one accepted. A golden set run side by side turns “seems fine” into a table of exactly what changed.
Codebase and provider consoleAbout 30 min
1. Find every call and its deadline
Search the codebase for the old model id and for anywhere a model is chosen from configuration:
grep -rnE 'claude-sonnet-4-5|gpt-[0-9]|model[_-]?id|MODEL' \
--include='*.py' --include='*.ts' --include='*.js' --include='*.yaml' --include='*.json' --include='*.env' .Then check what is really being called, because configuration drifts from code. Anthropic’s Console has a usage export (Usage, then Export) that breaks usage down by API key and model; most providers and gateways have something similar. List each feature that calls the model, how many requests a day it handles, and the retirement date of the model it uses. The feature with the most traffic or the strictest output format goes first.
Read the provider’s migration guide for the target model now, not after the first failure. It lists the behaviour and parameter changes the provider knows about.
Logs and editorAbout 90 min
2. Freeze a golden set from real traffic
A golden set is a fixed list of inputs with checks on the outputs, and it is the whole basis of the comparison. Build it from production logs, with personal data removed:
- Typical cases, sampled at random, so the set reflects what users really send: about 60% of it.
- Hard cases you know about: past bugs, long inputs, inputs in other languages, tool-heavy requests.
- Cases where the old model fails today, marked as such. The new model may fix them; you want to know.
- Cases that must be refused or escalated, so a more helpful model does not start answering them.
Fifty to two hundred cases is enough for most features. For each, write checks you can run: the output parses, has the required fields, stays under a length, mentions or does not mention something, escalates when it should. Save the set and do not change it during the migration. If you add a case, add it for both models.
The golden set recipe for RAG goes deeper on choosing cases, and the Promptfoo tutorial covers the assertion types.
TerminalAbout 45 min
3. Run the old and new models side by side
Promptfoo can run several providers against the same tests and show the results in one table. Give each provider a label, and let the new model run both the current prompt and a copy you will edit in step 5:
# yaml-language-server: $schema=https://promptfoo.dev/config-schema.json
description: Model migration, support reply drafter
prompts:
- id: file://prompts/reply-current.txt
label: current-prompt
- id: file://prompts/reply-candidate.txt
label: candidate-prompt
providers:
- id: anthropic:messages:claude-sonnet-4-5-20250929
label: old-model
prompts: [current-prompt]
config:
max_tokens: 1024
- id: anthropic:messages:claude-sonnet-5-5
label: new-model
prompts: [current-prompt, candidate-prompt]
config:
max_tokens: 1024
defaultTest:
assert:
- type: is-json
- type: latency
threshold: 8000
- type: javascript
value: JSON.parse(output).reply.length <= 1200
tests: file://golden/cases.yamlStart with reply-candidate.txt as an exact copy of reply-current.txt. Each case in golden/cases.yaml has a description that starts with a stable id, so you can refer to it later:
- description: "escalate-03: legal threat goes to a person"
vars:
ticket: "If this isn't fixed today my lawyer will be in touch."
assert:
- type: javascript
value: JSON.parse(output).escalate === trueRun it without the cache, because the latency check needs fresh calls, and twice, to see which failures are noise:
npx promptfoo@0.126.0 validate -c promptfooconfig.yaml
npx promptfoo@0.126.0 eval --no-cache --repeat 2 -o results/baseline.json
npx promptfoo@0.126.0 viewThe view shows each case as a row with the old model, the new model with the current prompt, and the new model with the candidate prompt side by side.
Promptfoo viewer and your AI assistantAbout 45 min
4. Sort every difference into a kind of regression
Pass rates hide what changed. Filter the view to cases where the old model passed and the new one failed, and read each pair of outputs. Most differences fall into a few kinds: format (JSON wrapped in prose, Markdown where you wanted plain text), length, tone, refusals or escalation, tool calls, and facts. Write each failing case id under its kind.
With many failures, an assistant can do the first sort. Export the failing pairs and paste them in:
Read the “check to review” list carefully. Some failures are the test being too strict for wording that is fine, and some are the new model being better. Fix those checks for both models, never for one.
Editor and terminalAbout 45 min
5. Fix the prompt and the request for the new model
Make changes to reply-candidate.txt and to the new provider’s config only, one kind of regression at a time, and re-run after each:
npx promptfoo@0.126.0 eval --no-cache --filter-providers new-model -o results/candidate.jsonTypical fixes:
- Format: state the format once, plainly, at the end of the prompt (“Reply only with the JSON object”), or switch to the provider’s structured output feature if you have not already.
- Length: give a limit in sentences or words; newer models often follow these more closely than older ones did.
- Parameters: check every request parameter against the new model. Anthropic’s deprecations page records that
temperature,top_pandtop_kwere removed in API version 2026-10-21, and that earlier API versions return an error when they are set to a non-default value on Claude 4.7 and later models. Code that setstemperature: 0for consistency will fail on the new model until you take it out. - Over-correction: remove old workarounds (“DO NOT use bullet points!!”) that the new model no longer needs; they can make it stiff.
Stop when the candidate prompt on the new model passes every case the old model passed, or each remaining difference is one you have decided to accept and written down.
Terminal and spreadsheetAbout 20 min
6. Compare cost and latency on the same cases
A model with a lower price per token can still cost more if it writes longer answers or uses more input tokens for the same text. Measure on the golden set, not on the price list. From the final run, take per provider: median and 95th percentile latency, average input and output tokens, and total cost. Promptfoo records token usage and latency for each result in the JSON output, and its cost assertion can fail a case above a threshold if the provider reports cost.
Put the numbers in a small table with the old model as the baseline, and multiply by your daily request count from step 1 for a monthly estimate. If the new model is slower at the 95th percentile, check whether your timeouts and any streaming code still fit.
Feature flags and monitoringAbout 25 min
7. Roll out behind a flag and keep a way back
Ship the new model and the candidate prompt together, behind a flag that chooses them per request. A gateway such as LiteLLM can do the split and the fallback if you already use one.
- Internal first: turn it on for your own team for a day and read real outputs.
- Small share: 5% of traffic, with the old model as automatic fallback on errors.
- Watch: error rate, latency, output length, escalation rate, and user signals such as thumbs-down or follow-up messages. Compare with the old model’s traffic over the same hours.
- Widen: 25%, 50%, 100%, a day or more each, depending on traffic.
- Retire: when the new model has carried all traffic for a week with no regression, remove the old model id from code and configuration, before the provider’s retirement date.
Add the golden set to CI so the next migration starts from a working baseline: the Promptfoo in CI tutorial shows how.
Check it worked
Verification checklist
0 of 7 done
When it goes wrong
If every request to the new model fails with a 400 error, look at the request, not the prompt. The usual cause is a parameter the new model rejects, such as a sampling parameter, or a beta header or tool type it does not accept. Run one case with verbose logging (npx promptfoo@0.126.0 eval --verbose --no-cache --filter-first-n 1) to see the provider’s error message. Do not shorten --verbose to -v: on the eval command, -v means --vars.
If the new model fails many cases on format alone (JSON in a code fence, an extra sentence before the object), fix the parsing or move to structured outputs before tuning anything else. Format failures hide the real differences behind them.
If pass rates jump around between the two runs, the checks are too sensitive to wording or the cases are ambiguous. Replace exact-match checks with checks on the fields that matter, and drop or rewrite cases where two reasonable people would disagree on the right answer.
If production complaints rise after rollout while the golden set still passes, the set is missing a kind of input. Find three of the complaints, add them as cases, and run both models again. This is how the set gets better each migration.
Variations
For a change of provider rather than a newer model from the same one, the steps are the same and step 5 is bigger: system prompt placement, tool definitions and structured output syntax all differ. A gateway or an SDK that abstracts providers keeps the change in one place. To choose the candidate model in the first place, read how to choose an LLM.
For a RAG feature, also evaluate retrieval with a golden set, because retrieval quality and answer faithfulness can change with the model even when the format checks pass. For a coding agent rather than an app, evaluate coding agents on your repository uses the same side-by-side idea with your own tasks.
Related LLMOps guides
The regression eval entry defines the idea behind this recipe. The LLMOps, observability and cost path covers tracing and cost control, which make step 7’s monitoring possible.
Outcome and tools
- Outcome
- Your app runs on the new model behind a flag, with a side-by-side eval showing no regressions on a frozen golden set, measured cost and latency, and a dated plan to remove the old model.
- For
- Developers, ML engineers
- Agent Skills
Related
- How to choose an LLM for a task without trusting leaderboards
A method for choosing an LLM: build 20 test cases from your own work, then compare accuracy, cost per correct answer, latency and data terms. No rankings.
- Run LLM evals in CI with promptfoo
Write a promptfoo config with deterministic and model-graded assertions, run it in GitHub Actions, fail the build on regressions and keep the bill small.
- Evaluate RAG answers with a golden dataset
Set up RAG evaluation with a golden dataset and promptfoo: score retrieval, correctness and grounding for every question, and fail CI when answer quality drops.
- Regression eval
An eval run automatically on every prompt, model or code change, so that a drop in quality is caught before it reaches users.
- LLMOps: observability, evals and cost
Learn LLMOps in practice: trace every request, gate changes with evals in CI, calibrate judges and keep token spend visible and under control in production.