Instruments That Could Not Fail
A routing differential came back byte-identical against a router I had broken on purpose. It was one of several measurements in one project that reported a confident number about nothing.
Aegis, my self-hosted voice assistant, makes a routing decision on most turns: a deterministic classifier predicts which tool a question needs and can force the model to call it. Forcing is a latency optimization. It also makes the most obvious accuracy metric worthless, and that turned out to be the first of several measurements in this project that produced a confident number about nothing.
A score that graded itself
The natural metric is "did the model call the tool the classifier predicted?" On a forced turn the answer is always yes, because the model was told to. So forced turns are excluded, and only a shadow sample counts: turns where the prediction is recorded but not enforced.
My reproducible test harness and its scorer got this wrong in two ways at once. It built the router with neither a routing log nor a shadow sampler, so no decision ever reached the turn record. And the scoring predicate checked that a tool was predicted and matched, never whether the turn had been forced. Nine forced turns scored 9/9, a metric answering a question it had already answered.
The live log had the mirror-image problem. Across 92 recorded turns, five predicted a tool and three were shadow-sampled, and the two sets were disjoint: every turn that predicted a tool was forced, and every shadow turn predicted nothing. Scored turns: zero. At the shadow rate then deployed, 20 scored turns would have taken roughly 2,500 turns of speaking.
A score from the wrong file
When I went to capture a baseline, the report script run with no argument resolved the log path the way the host resolves it. That is a different, nearly empty file from the one the container writes. It printed:
scored turns: 1 of 5
routing accuracy: 100%
One turn, from a record older than the shadow field itself. That 100% could easily have become the reference for a stop rule ("if routing accuracy drops, revert"). The fix was trivial: always pass the path. What stayed with me is how close a number with no n beside it came to becoming a gate.
A differential that could not see the bug
Later I moved the routing code into a new module and wanted proof the move changed nothing. I built a differential over the classifier's whole decision space: every cue, bare, embedded in a sentence, upper-cased and split across two transcripts, crossed with eleven tool configurations and four shadow regimes. That came to 23,139 rows per arm, each recording the full decision. The two arms were byte-identical, same sha256.
Then I broke the router on purpose. I reversed the precedence between a learned preference and a stood-down route, which is the exact ordering the move was meant to protect. The differential still said byte-identical. So did the 23-test routing suite.
The cause was one configuration. The only row that paired a distrusted route with a preferred one used a write request, and write requests return "no tool" before either branch is reached, so the two branches were never ordered against each other. With configurations that did order them, three deliberate mutations changed:
| Mutation | Rows changed |
|---|---|
| stood-down checked before the learned override | 471 |
| speculate on the forced tool, not the prediction | 18,764 |
| a shadow turn forces the prediction anyway | 3,228 |
My notes from that day call it the third time in the project that an instrument passed because it could not fail. The rule I wrote under it: mutate it before believing it.
Harness numbers are not live numbers
The same trap shows up in latency. My measurements file had a confident paragraph about tool turns, written from 24 scripted headless turns against a warm model: tools cost about 0.58s of voice-to-voice, 93% of it the model being called a second time, because the first response is a tool call with nothing to say.
That paragraph is true of the harness and false of live sessions. Once the turn record split the time before and after the tool, the first seven live tool turns read the other way:
| Live tool turns, n=7 | p50 | p95 |
|---|---|---|
| request to the tool running | 3.181s | 21.815s |
| the tool itself | 0.070s | 0.120s |
| result to speech | 1.090s | 1.195s |
The second round trip was the cheap, stable half. All of the expense and all of the variance sat in the first.
Even that correction needed correcting. A note-taking turn spent 21.7s before a 6ms tool ran, three times in three sessions, and I recorded it as structural. Segmenting the log by deploy showed the three worst were each the first turn of a session, against a model that had been unloaded, and the three-call turns stopped once the model was warmed when a session opens. Four session openers in the following days is not proof, and I wrote that down too, next to a new rule: segment a log by deploy before quoting a distribution from it.
What a trustworthy instrument looked like
The repaired harness earned its place by refusing to vary. Two independent runs over identical input produced identical scored sets, 30 of 30 in each, every tool 3/3 in both. A zero noise floor is what makes a stop rule usable, because one mismatch after a change is then signal.
It still isn't production. The harness builds its own pipeline with a different tool catalogue, so it stays its own series beside the live figure, 13 of 14 or 93% with a 95% interval of 69% to 99%, and the two are never pooled.
The habit that stuck
After the differential, I started confirming new tests against a mutation that should break them, and saying so in the commit. It keeps finding things. A cancellation test used a fake object with a convenient method, so the real lookup could have returned nothing forever and the suite would have stayed green.
Mutating an instrument costs a few minutes. Skipping it cost me a 100% from one record, a 100% from nine turns that graded themselves, and a byte-identical diff against a router I had broken by hand.
Written by
Adrian Romo
Senior Backend Engineer: Python backends, AWS, enterprise integrations, realtime voice systems, and AI infrastructure.
Related
Keep reading
Four Hours of CPU Nobody Asked For
In October this site was suspended on Vercel's free tier and its Neon database ran out of compute. Traffic was not the cause. Pages regenerating on timers were, and removing the timers took daily CPU from minutes to seconds.
The Update Cron That Patched Nothing
A weekly LXC update job fired on schedule for about sixteen months and installed nothing: a 404 script URL, with the error sent to /dev/null. Auditing every update mechanism found zeroes that meant nothing.
The Tool Nobody Called
I gave my homelab's agents one tool for grounded answers. It served 1 of 69 lookups, and my voice assistant called it in 0 of 32 turns. The nudges meant to fix that had been going to a debug log.
Keep going
Where to next?
Browse more technical writing, see the engineering case studies, or reach out directly.