Drift After a Model Update: Tag Every Event, Split the Dashboard by Version, Alert Against a Baseline
After a model update errors stay at zero and the dashboard stays green, yet replies grow from 29.3 to 47.8 tokens, refusals go from 0 to 17 percent and the help link drops to 67 percent. Split by model version and compare with a baseline, and four alerts fire where fixed thresholds on a blended row stay silent.
What you will learn
- Turn every model call into an event tagged with the model that really answered
- Split dashboard rows by model version and see what a blended row hides
- Replace fixed thresholds with drift rules against a stored per-version baseline
- Make the alert name the model change and ask for a golden-set replay
Before you start
- SLIs and SLOs for an LLM service
- Pinning Claude model IDs and upgrading safely
The on-call engineer for SupportDesk opens the dashboard. Errors are at zero, every call came back as a normal success, all green. And the model is the new one.
Look closer. Replies have grown from 29 tokens to 48. Refusals went from none to 17 percent. Replies that carry the help link dropped from all of them to two out of three. Nobody was paged. A model update rarely raises an error. It changes what the answers look like, and your alerts have to notice.
An oven that still switches on
A baker's oven: the power light is on, it still heats, no alarm sounds. That's what "no errors" looks like. Now a new part is fitted, and the loaves bake differently: longer, paler, uneven.
How do you catch that? You compare this oven with itself, from before the part was fitted. That's a baseline, kept for each version. The alarm was built for broken; this is changed.
Where the monitor sits
The monitor wraps every model call. The answer goes up to the caller as normal, and a small event goes sideways to the dashboard and the alerts. The project runs on a stand-in model (the Anthropic SDK on an httpx mock transport with an old and a new model scripted), so no API key is needed, the replies are test replies, and the token numbers are made up. The fields it reads, model, stop_reason and usage, are real Messages API fields.
monitor.py: one call, one event
"""One call, one event: the model that answered, the usage, the stop_reason and a behaviour check."""
from stand_in import LINK
def ask(client, model, ticket):
r = client.messages.create(model=model, max_tokens=256, messages=[{"role": "user", "content": ticket}])
text = r.content[0].text if r.content else ""
return {"model": r.model,
"tokens_in": r.usage.input_tokens,
"tokens_out": r.usage.output_tokens,
"stop_reason": r.stop_reason,
"has_link": LINK in text}
- The model is read from the response,
r.model, not from your own settings. That's the model that really answered. - A refusal shows up in
stop_reasonas a normal answer, not an error. has_linkis a cheap behaviour check: does the reply carry the help link?
dashboard.py: one row per version, plus the blend
An excerpt:
def stats(events):
answered = [e for e in events if e["stop_reason"] == "end_turn"]
return {"calls": len(events),
"out_per_reply": round(sum(e["tokens_out"] for e in answered) / len(answered), 1),
"refusal_pct": round(100 * sum(e["stop_reason"] == "refusal" for e in events) / len(events)),
"check_pct": round(100 * sum(e["has_link"] for e in events) / len(events))}
def by_model(events):
models = sorted({e["model"] for e in events})
return {m: stats([e for e in events if e["model"] == m]) for m in models}
Output tokens are averaged over answered replies only, since a refusal has no reply. The refusal rate and the link check are over all calls. by_model gives each version its own row; the render function then adds one blended "all models" row, because that's where most dashboards stop.
The alerts we're replacing
"""The before version: fixed thresholds on the blended numbers. It watches for breakage, not for change."""
MAX_ERROR_PCT, MAX_OUT_PER_REPLY = 5, 60
def check(window, history):
calls = history + window
errors = [e for e in calls if e["stop_reason"] not in ("end_turn", "refusal")]
out = [e["tokens_out"] for e in calls if e["stop_reason"] == "end_turn"]
alerts = []
if 100 * len(errors) / len(calls) > MAX_ERROR_PCT:
alerts.append("error rate over 5%")
if sum(out) / len(out) > MAX_OUT_PER_REPLY:
alerts.append("out tokens per reply over 60")
return alerts
Two numbers chosen once, every version in one pile, and a refusal never counts as an error. This code can only see breakage.
alerts.py: each version against its baseline
"""The drift version: compare each model version with its own baseline, on behaviour signals."""
from dashboard import stats
RULES = [("out_per_reply", "rel", 0.30), # output tokens per reply up more than 30 percent
("refusal_pct", "abs", 10), # refusal rate up more than 10 points
("check_pct", "drop", 15)] # replies with the help link down more than 15 points
def drift(baseline, window):
base, now = stats(baseline), stats(window)
model = window[0]["model"]
alerts = []
for metric, kind, limit in RULES:
delta = now[metric] - base[metric]
if kind == "rel" and delta > limit * base[metric]:
alerts.append(f"{metric} {now[metric]} vs {base[metric]} (+{round(100 * delta / base[metric])}%)")
elif kind == "abs" and delta > limit:
alerts.append(f"{metric} {now[metric]} vs {base[metric]} (+{delta} points)")
elif kind == "drop" and -delta > limit:
alerts.append(f"{metric} {now[metric]} vs {base[metric]} ({delta} points)")
if alerts and model != baseline[0]["model"]:
alerts.append(f"model changed: {baseline[0]['model']} -> {model}, replay the golden set")
return alerts
Three rules, all about behaviour. The baseline is the last good window before the change (day 1 here). If a rule fires and the model has changed, the alert says so and asks for a replay of the golden set.
Three days of tickets
Six tickets a day. Days 1 and 2 run on the old model; on day 3 the model is updated. Here is what python run_all.py printed:
dashboard day 1
model calls out/reply refusal% check%
claude-haiku-5-5 6 29.3 0 100
all models 6 29.3 0 100
fixed thresholds: all green
dashboard day 2
model calls out/reply refusal% check%
claude-haiku-5-5 12 29.3 0 100
all models 12 29.3 0 100
fixed thresholds: all green
drift check: no drift
dashboard day 3
model calls out/reply refusal% check%
claude-haiku-5-5 12 29.3 0 100
claude-sonnet-5-5 6 47.8 17 67
all models 18 34.8 6 89
fixed thresholds: all green
drift check: 4 alerts
ALERT out_per_reply 47.8 vs 29.3 (+63%)
ALERT refusal_pct 17 vs 0 (+17 points)
ALERT check_pct 67 vs 100 (-33 points)
ALERT model changed: claude-haiku-5-5 -> claude-sonnet-5-5, replay the golden set
Days 1 and 2 match, so day 1 is a fair baseline. On day 3 the new model gets its own row, and every behaviour number has moved. The blended row averages twelve old calls with six new ones and reads 34.8 tokens, 6 percent refusals and 89 percent links: nowhere near the fixed 60-token or 5 percent error lines. So the fixed thresholds stay green one more time, and the drift check raises four alerts.
The last alert is the most useful one. It tells the on-call engineer the likely cause and the next step: replay the golden set against the new version, the way a safe model upgrade does before rollout. For the error-budget side of alerting, where a promise burns down over time, see SLIs and SLOs for an LLM service.
Common mistakes
- Adding more fixed thresholds. They watch for broken, and nothing is broken.
- Paging on every metric that moves. Noise trains people to ignore the pager. Compare against a baseline with a limit instead.
- Waiting for the first complaint. By then customers have met the change.
- Reading the model from your config. Read
r.modelfrom the response, so the event records what really answered. - Stopping at the blended row. A minority version, here 6 of 18 calls, gets averaged away.
Quick recap
| Step | What it does | In the run |
|---|---|---|
| Tag | Every event carries the model that answered | r.model |
| Split | One dashboard row per model version | Old 29.3 tokens, new 47.8 |
| Compare | Behaviour signals against a stored baseline | +63%, +17 points, -33 points |
| Replay | The alert names the model change and asks for the golden set | 4th alert |
Try it yourself
Pick one cheap behaviour check for your own app, like has_link here: a required phrase, a JSON field that must exist, a citation. Log it per call with the model from the response, and set a drop limit against last week's baseline.
Related course on Udemy
Claude Certified Developer - Professional (CCDV-P) Exam Prep
Claude agents in production: reliability, observability, evals, cost, guardrails and fleets.View on Udemy ↗: Claude Certified Developer - Professional (CCDV-P) Exam Prep (paid course, opens in a new tab)Related posts
Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed
When the main model goes down, the backup has to be allowed to take the data, able to read the whole request and tested before the bad day. A simulated four-model chain for an EU customer: a 6,000-token request lands on mid-eu, flagged degraded; a 10,000-token request is served by nobody, on purpose.
Back Pressure for LLM Traffic: Bound the Queue, Give Chat Its Own Lane, Count Tokens, Cancel When the Caller Leaves
A bulk upload buries the chat. In a small simulation, one shared queue grows to 199 waiting and the middle chat answer takes 80.2 s. A bound plus a chat lane brings it to 0.35 s while 178 bulk jobs are told to retry in 10 s, and cancelling abandoned calls saves 21,000 wasted tokens.
Load Balancing LLM Traffic: Count the Work, Weigh the Prefix Cache, Check Real Health, Drain Before Deploys
Six GPU replicas, two at 95% and four at 30%: round robin counts requests, and requests aren't equal. In a small simulation, least outstanding requests cuts p95 from 6.52 s to 3.05 s, prefix affinity lifts cache hits to 95% but pushes p95 to 11.45 s, a real health check takes errors from 48 to 2, and draining cuts 0 answers instead of 4.
A Message Queue for Document Ingestion: At Least Once, Leases, an Idempotent Consumer and a Dead Letter Queue
A queue doesn't lose a document, but it can hand one out twice. In a small simulation, a worker crash makes document two go from 3 to 6 chunks and the index holds 11 when the documents hold 8. An idempotent consumer brings it back to 8 with the same two deliveries, and a limit of three tries moves a poison file to a dead letter queue.
