Release engineering for production AI
Step 13 of 14. Prompts, models, retrieval settings and infrastructure all change behaviour. Version them together, test them in layers and release them in small, reversible steps.
Release engineering in 60 seconds
- More than code: prompts, model settings, tool definitions, ranking, chunking, guardrails, indexes and test sets all change behaviour, so all of them are versioned.
- Test in layers: unit, integration, security, AI evaluation and load tests, including the failure cases.
- Automate the path: a pipeline runs checks, builds, tests, stages, smoke tests, canaries and expands only while metrics stay healthy.
- Release gradually: canary, blue-green and per-store flags limit the blast radius, with rollback rules written before the release.
- Infrastructure is code: reviewed, repeatable and protected, since its state and plans can leak secrets.
The problem it solves
A feature that works on a laptop can fail in production for dull reasons. Permissions are tighter. Traffic is higher. A dependency moved on a version. The model behind an alias changed overnight. Most of all, a prompt tweak that improves one example can quietly damage ten others.
Imagine someone asks for shorter answers. The wording change reads well in three samples. Two weeks later, support finds that the scanner sync answer now drops the step that restarts the sync service. Without versioning and regression tests, nobody can say which change did it, and nobody can go back safely. Release engineering makes every change reviewable, repeatable, testable and recoverable.
Treat every behaviour-shaping asset as code
Source code is not the only thing that decides what Store Assist says. Version each of the following, and know which versions produced any given answer.
- The prompts, for the whole assistant and for each task.
- Which model is called, with settings such as temperature and output limits.
- Tool schemas, and the rules that check what goes into them.
- How search is tuned and how results are ordered.
- How documents are split and indexed.
- The guardrail rules.
- Test datasets, with the pass marks attached.
Versioning gives you three abilities: to say which configuration produced a particular reply, to compare two versions side by side, and to restore a known good state when a release goes wrong.
A release manifest that moves as one unit
Individual versions are not enough, because the parts depend on each other. A prompt written for one model can misbehave on another. A ranking change can need a re-built index. Bundle the compatible set into a single manifest, give the bundle one version, and release and roll back the bundle, not the pieces.
# One manifest = one releasable unit of AI behaviour.
MANIFEST = {
"release": "2026-11-09.3",
"prompt_version": "assist-prompt-41",
"model_route_table": "routes-v17", # versioned config, see step 8
"tool_schema_version": "tools-v12",
"retrieval": {"ranking": "rank-v6", "chunking": "chunk-v4", "index": "idx-2026-11-08"},
"guardrail_policy": "guard-v9",
"eval_set": "golden-v22",
}
# Explicit thresholds. A release that misses any of them does not ship.
GATES = {
"groundedness_min": 0.95,
"correct_escalation_min": 0.98,
"tool_call_validity_min": 0.99,
"injection_block_min": 0.99,
"max_regression_vs_current": 0.02, # no dimension may fall by more than 2 points
"p95_full_latency_ms_max": 8_000,
"cost_per_resolved_gbp_max": 0.03,
"isolation_violations_max": 0, # zero tolerance
}
def passes_gate(candidate: dict, current: dict) -> tuple[bool, list[str]]:
"""Compare offline evaluation results for a candidate against the live release."""
failures = []
for key in ("groundedness", "correct_escalation", "tool_call_validity", "injection_block"):
if candidate[key] < GATES[key + "_min"]:
failures.append(f"{key} below floor")
if current[key] - candidate[key] > GATES["max_regression_vs_current"]:
failures.append(f"{key} regressed")
if candidate["p95_full_latency_ms"] > GATES["p95_full_latency_ms_max"]:
failures.append("latency over target")
if candidate["cost_per_resolved_gbp"] > GATES["cost_per_resolved_gbp_max"]:
failures.append("cost over target")
if candidate["isolation_violations"] > GATES["isolation_violations_max"]:
failures.append("isolation violation")
return (not failures, failures)
The names and values are examples. The idea is that the gate is code, lives beside the manifest, and answers yes or no without a meeting.
Testing before deployment
A sound strategy blends ordinary software tests with checks designed for model behaviour. Each layer catches a different kind of fault.
| Test layer | What it proves | Store Assist example |
|---|---|---|
| Unit | Single components behave | Input validation, permission checks, cost arithmetic, tool argument parsing |
| Integration | Services work together | Retrieval, model call, inventory service, ticketing and queue in one flow |
| Security | Attacks and bypasses fail | Cross-colleague access, hidden instructions in a supplier manual, skipping manager approval |
| AI evaluation | Answers meet quality targets | Golden set scored for correctness, groundedness, tool choice |
| Load | Behaviour holds under traffic | The 10 requests a second peak, the 70 in flight agent flow, sustained stress |
Test failure as carefully as success. What happens when retrieval is down? When the model returns a malformed tool argument? When a colleague loses a permission while a workflow is mid-flight? When the stock service answers after the deadline? Each should have a named test and an expected, safe behaviour.
The pipeline from commit to production
A continuous integration and delivery pipeline turns the checklist above into something nobody can forget. A typical flow for a Store Assist change is:
- Lint, static checks and the fast unit suite.
- Package the service as an image or artefact.
- Integration tests, then the security suite.
- A chosen subset of AI evaluations, with the full set nightly.
- Staging deployment.
- Smoke tests on the staged build.
- A small share of live traffic.
- Metrics reviewed, with the rollout widened only while they stay healthy.
Any CI service can run this. Pick the one your teams already operate. What matters is that the process is repeatable and visible, not an undocumented sequence that one engineer carries in their head.
Releasing in small, reversible steps
No colleague needs to be first. Three techniques limit the blast radius, and they combine well.
- Canary: send a small slice of traffic to the new version while the old one stays up.
- Blue-green: keep two full environments and switch traffic when the new one is ready, with an instant switch back.
- Feature flags: switch a model, prompt or search strategy on for chosen users only, and off again without a deployment.
For Store Assist, a new routing policy first goes to 5 pilot stores. That is 1.25% of the estate and about 150 colleagues, enough for a week of comparisons without risk to the other 395 stores. The team sets speed, quality, spend and handover rates against the control group, then expands in steps.
| Stage | Scope | Typical duration | Move on when |
|---|---|---|---|
| Shadow | Run the candidate on copies of live requests, no user impact | 2 to 3 days | Offline scores match or beat current |
| Pilot | 5 stores by flag | 5 trading days | All canary metrics within limits |
| Wave one | 40 stores (10%) | 3 trading days | No rule breached, no new incident class |
| Wave two | 200 stores (50%) | 3 trading days | Same, plus cost per resolved question on target |
| Full | All 400 stores | Ongoing watch | Old release kept ready for 14 days |
Rollback rules agreed before release
Decide what triggers a rollback while everyone is calm, and write the rules down. Automated rollback should handle the clear cases. A person decides the ambiguous ones.
| Signal | Automatic rollback when | Reason |
|---|---|---|
| Error rate | Above 2% for 5 minutes, or double the control group | Something is broken |
| p95 full answer time | Above 10 s for 10 minutes | Target is 8 s, so this is a clear breach |
| Live groundedness sample | More than 3 points below control with enough samples | Answers are drifting from the evidence |
| Cost per request | More than 25% above control | Likely loop, retry storm or bloated context |
| Wrong tool actions | Any confirmed unauthorised or incorrect write | Real-world harm |
| Escalation rate | Falls or rises more than 30% against control | Either hiding hard cases or over-escalating |
A rollback plan must cover more than the application build. Be ready to restore the previous prompt, model settings, ranking strategy and index version. If the new release rebuilt the index, keep the old index alive until the canary has finished, since a rebuilt index cannot be undone by redeploying code.
Infrastructure as code
Production rests on networks, compute, data stores, queues, permissions, alerting and pipeline settings. Changing these by hand leaves environments that nobody can reproduce. Describe them in version-controlled configuration, using an infrastructure-as-code tool, and review changes like any other code.
- Rebuild on demand: a test environment should be recreated from reviewed configuration, not from someone's memory of console clicks.
- Review the plan, not only the code. The planned change set shows what will really be altered or destroyed.
- Protect state: the tool's state files, deployment credentials and plan output can contain secrets and reveal the layout of your environment. Store them encrypted, with narrow access and audit.
- Separate duties: the identity that deploys to production is not one a developer uses day to day.
- Detect drift: compare running infrastructure with the code on a schedule and treat differences as incidents.
Store Assist, worked through
The team wants the routing policy that sends simple procedure questions to a smaller model. Walk it through.
- Manifest: route table moves from routes-v17 to routes-v18. Everything else is unchanged, so any difference is down to routing.
- Offline gate: on the golden set, groundedness is 96.1% against 96.4% for the live release, a fall of 0.3 points, inside the 2 point allowance. Cost per resolved question drops from £0.027 to £0.021.
- Shadow: two days of copied traffic show the same pattern.
- Pilot: 5 stores see the new route. At 36,000 requests a day across 400 stores, the pilot handles about 450 requests a day, so a week gives around 3,000 samples, enough to spot a 3 point movement in a rate near 95%.
- Watch: on day three the escalation rate in the pilot falls 35%. That trips the rule, because the cheaper model is answering sensitive cases it should hand over. The flag is switched off in under a minute.
- Fix: the router rule for sensitive intents is corrected, a case is added to the golden set, and the release restarts from the offline gate.
Note what saved the day: a rule on escalation rate, written in advance, and a flag that needed no deployment.
Change freezes around peak trading
Releases carry risk, and some weeks cannot afford it. Agree a calendar. Freeze changes to prompts, routes and infrastructure in the week before a major trading peak, and on the morning of any planned till software update. Allow only security fixes and rollbacks during a freeze, and require a named approver. After the peak, release the backlog in small batches rather than all at once, so that each change can still be understood.
Design decisions
- One manifest per release, with a single version identifier that appears in every trace.
- Gates as code, with thresholds reviewed like any other change and stored with the evaluation set version.
- Flag hierarchy: global, region, store group and store, with the narrowest scope winning and every flag owned and dated.
- Two-key rule for risky changes: a change to guardrails, tools with write access or access control needs a second reviewer from security.
- Index strategy: build new indexes beside the old, switch by alias, keep the old for the rollback window.
- Environment parity: staging uses the same configuration shape, the same model versions and a realistic data sample.
- Model version pinning: pin exact model versions in the manifest, and treat a provider's alias change as a release that runs through the gate.
Measuring it
- Gate pass rate and failure causes: which dimensions fail most often and why.
- Offline to online agreement: how well gate scores predict canary results. If they do not, improve the golden set.
- Canary sensitivity: the smallest regression your sample size can detect, and the time to reach it.
- Regression escape rate: problems found in production that the gate should have caught, each of which becomes a new case.
- Change failure rate and time to restore: the share of releases rolled back, and how long recovery takes.
When to use it, and how much of it
| Situation | Release approach | Why |
|---|---|---|
| Text tweak to an internal pilot assistant | Light gate, direct release to the pilot group | Small audience, easy recovery |
| Prompt, route or ranking change in production | Full gate, shadow, canary, flag | Silent regressions are the main risk |
| New tool with write access | Full gate plus security sign-off and a narrow first wave | Mistakes change real data |
| Model version change by the provider | Treat as a release, run the whole gate | Behaviour can move without code changes |
| Emergency fix | Shortened path with focused tests and a named approver | Speed matters, but rollback still ready |
Trade-offs
| Dimension | Effect | What to do about it |
|---|---|---|
| Speed | Gates, shadow runs and waves add days | Reserve the full path for risky changes and keep a fast lane for safe ones |
| Cost | Evaluation runs and a second environment cost money | Run a subset on every change and the full set nightly |
| Safety | Small waves limit damage | Pilot with stores that reflect the range of the estate |
| Complexity | Manifests and flags need discipline | Retire flags on a date and keep an inventory |
What this means for your role
Common mistakes
Step checklist
- Every behaviour-shaping asset is versioned and listed in one release manifest.
- The manifest identifier appears in every trace and log line.
- Unit, integration, security, evaluation and load tests exist, with failure cases.
- The evaluation gate has numeric thresholds and a regression allowance, and runs in CI.
- Releases pass through staging, smoke tests, a canary and widening waves.
- Rollback conditions are written down, partly automated and rehearsed.
- Old indexes and model pins are retained during the rollback window.
- Feature flags can be set per store and are owned and dated.
- Infrastructure is code, plans are reviewed, and state and credentials are protected.
- A change freeze calendar covers peak trading periods.
Further reading
- Observability and evaluation: the metrics that power gates and rollbacks.
- Model selection and routing: the route tables that are versioned here.
- AI gateway and resilience: model pinning and deprecation planning.
- Evaluation and observability: the wider topic.
- Circuit breaker: another way to limit damage when something breaks.
Releases that are small, measured and reversible turn change from a worry into a routine. With that in place, you can see the whole design at once. Next: Step 14: End-to-end design and checklist.