By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
The serving lesson ended with a deployment checklist, and the prompt-template lesson made each prompt a versioned configuration. This lab connects the two: a deploy is a named configuration - prompt version, model, temperature, tool policy and step cap - and a rollback is flipping back to the previous configuration, not scrambling for a code rollback while customers wait.
The lab has four parts: fingerprint the configuration so every answer can name what produced it, decide promote or rollback with pre-agreed gates, keep health checks cheap, and rehearse the incident checklist. The scenario is a canary where the candidate is mostly healthy but its eval score drops below the accepted threshold.
A version string on the prompt is not enough. The same prompt behaves differently with a different model, temperature, tool policy or step budget, so the unit you deploy and roll back is the whole configuration. Hashing the config gives you a short fingerprint that fits in a log line and a trace attribute.
The snippet computes fingerprints for the current baseline and a candidate, evaluates five pre-written canary gates, and prints the decision. Four gates pass; the eval score fails; the decision is rollback, and the rollback target is the baseline fingerprint.
"""A config fingerprint and a canary gate for a prompt deployment."""
import hashlib
import json
BASELINE = {
"prompt_version": "support-v12",
"model": "openai:gpt-4.1-mini",
"temperature": 0.2,
"tool_policy": "reader+queue",
"max_steps": 6,
}
CANDIDATE = {**BASELINE, "prompt_version": "support-v13"}
def fingerprint(config):
payload = json.dumps(config, sort_keys=True).encode("utf-8")
return hashlib.sha256(payload).hexdigest()[:8]
OBSERVED = {
"error_rate": 0.011,
"p95_ms": 1580,
"eval_score": 0.88,
"fallback_rate": 0.02,
"approval_backlog_minutes": 12,
}
GATES = {
"error_rate": (OBSERVED["error_rate"] <= 0.02, "rollback above 2%"),
"p95_ms": (OBSERVED["p95_ms"] <= 2000, "rollback above 2000 ms"),
"eval_score": (OBSERVED["eval_score"] >= 0.90, "rollback below 0.90"),
"fallback_rate": (
OBSERVED["fallback_rate"] <= 0.05,
"rollback above 5%",
),
"approval_backlog_minutes": (
OBSERVED["approval_backlog_minutes"] <= 60,
"rollback above 60 min",
),
}
print("baseline:", BASELINE["prompt_version"], fingerprint(BASELINE))
print("canary: ", CANDIDATE["prompt_version"], fingerprint(CANDIDATE))
for name, (passed, rule) in GATES.items():
print(f"{name:>24}: {'pass' if passed else 'FAIL'} ({rule})")
promote = all(passed for passed, _ in GATES.values())
print("decision:", "promote" if promote else "rollback")
if not promote:
print(
"rollback to:",
BASELINE["prompt_version"],
fingerprint(BASELINE),
)Four of five gates pass, which is exactly the situation that tempts a team to monitor instead of act. The gates were written before the canary started, so the decision is mechanical: a quality gate below its floor means rollback, regardless of how green the latency graph looks. If the eval score had been 0.91 the same script would print decision: promote - same gates, different evidence.
The fingerprints make the rest of the incident cheap. Every trace and log line can carry c13a3d76 or 95019305, so 'which configuration answered this customer?' is a query rather than an archaeology project. Rolling back restores the stored baseline configuration; no new build is required.
A canary is only useful if each stage has a gate and a failure action. Write the stages down with the gates; a canary with no rollback criteria is just a slower full deploy.
| Stage | Traffic | Gate before the next stage | If it fails |
|---|---|---|---|
| Shadow replay | 0% - replay recorded requests | No errors, and the eval score is not lower than the baseline on the same set | Fix locally; no customer has seen it |
| Canary | 5% | Error rate within 2%, p95 within 20% of baseline, eval score at or above the floor, fallback rate under 5%, approval backlog stable | Roll back to the previous fingerprint and keep the canary evidence |
| Ramp | 25-50% | Gates hold for a full traffic cycle, no new alert, cost per resolved ticket inside budget | Hold traffic, investigate the signal, roll back if quality moved |
| Full | 100% | Gates hold for 24-48 hours and the next scheduled eval run does not regress | Roll back, then run the incident checklist and add the failing case to the eval set |
Triggers belong in code or configuration next to the dashboards, not in a notes document. These are starting thresholds; set the numbers from a week of your own traffic and review them after every incident.
A liveness probe answers in milliseconds and touches nothing external. A readiness probe may check the vector store and the database briefly, but it must not call the model: a provider outage would mark every instance unhealthy at the same moment. During a canary, the health endpoint should also report the config fingerprint and the model name, so 'which version is this instance serving?' is a curl, not a meeting.
Run this with the request ids and the failing config fingerprint already in hand. The order matters: stop the bleeding, prove the platform is healthy, then reconcile anything that may have executed.
Key takeaways
Deploy a named configuration - prompt version, model, tool policy and limits - not just a prompt string.
Fingerprint the configuration so every trace can name what answered and a rollback restores exactly one stored target.
Write canary stages, gates and rollback triggers before traffic; one failed quality gate is enough to roll back.
Keep health checks cheap and expose the config fingerprint and a write kill switch next to them.
Roll back first, reconcile writes second, preserve evidence and add the failure to the regression suite.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.