Key takeaways
- ✓Measure the noise first. Six runs of the unchanged assistant passed 174 to 184 of 195 tests (89.2–94.4%): about 5 points of wobble with nothing changed. 49 tests passed in some runs and failed in others. A drop smaller than that wobble can't be seen from one run.
- ✓Not every change is a drop. Of six planted changes, an older, cheaper model (gpt-4o-mini) scored 4.8 points higher. Scrambling 3% of the search index cost 1.9 points, inside the wobble. Real breakages cost 6.8 to 68.7 points; a prompt that drops citations cost the most.
- ✓A paired test against a fixed reference cries wolf. The reference is each test's majority result in three early runs, which turns every test into a sure pass (186) or a sure fail (9). On an unchanged night, many more can slip down than climb up: run 5 had 15 down and 3 up (p = 0.0075). Replayed over 60 nights, 9 false alarms.
- ✓Leaving out the flaky tests made it worse: 37 false alarms. The 170 kept did the same thing in all three early runs, and 164 of them passed, so almost all can only go down (14 to 1 on run 5). A test that passed three times in a row still failed about one later run in 18. That's regression to the mean, which has nothing to do with regression testing.
- ✓The fix: compare each test with its own pass rate, pulled toward the suite's average because three runs is few (3 of 3 → 96%, 2 of 3 → 79%, 0 of 3 → 46%). Expected failures on a normal night: about 15; the alarm fires past about 26. 4 false alarms in 200 two-month replays, every real breakage caught (median 11 hours). The price: the 2-point change was caught only 8% of the time within a week.
- ✓An alarm should say what broke. The no-citation prompt: 141 newly failing tests, every one 'no citation', which points at the prompt. The scrambled index (39, mostly refused) and one-passage search (34, about half refused) look alike in the report; telling them apart needs a look at the index itself.
A QA agent runs the assistant through its tests every night, with nobody watching, and raises an alarm when quality drops. The hard part isn't catching a broken assistant. It's not crying wolf when nothing changed, because AI answers vary from run to run. This chapter measures that noise, replays two months of alarms for each rule, and shows why hiding the noisy tests made the alarm noisier.
The source is Lab 18 (Autonomous Systems), script 03_qa_agent.py, recorded in October 2026; the video uses that recorded run, no new calls. The course site, Quill Academy, and its people are made up. Every run of the suite is a real recorded run: gpt-5.4-nano answers, gpt-5.4-mini grades. The breakages are planted on purpose, and the two months of nights are simulated by mixing those real runs. The 195 tests are the suite chapter 57 grew from simulated users' questions. Script 03's hourly rules and its report table go beyond the video; they're in "Also in the lab" below.
The QA agent
The assistant answers learners' questions from nine short articles: it searches an index of article passages, takes the top three, and writes an answer that cites one. Each of the 195 tests asks a question, and passes when the grader says the answer is right and it cites its source (or it correctly declines). The agent's job, every night:
- Run all 195 tests.
- Apply an alarm rule to tonight's results.
- If it fires, say which tests newly fail, and how.
A nightly run of the full suite costs about 5 cents. But testing a rule for real would take two months of nights per rule and per change, and one two-month run says little about how often a rule cries wolf. So the lab ran the suite for real a few times per version and replayed 60 nights 200 times from those runs: each night, every test's result is drawn from one of its real runs. Rules are set from runs 1–3 of the unchanged assistant, and their false alarms are counted on runs 4–6, so the noise they're tested on is noise they weren't tuned on.
Normal noise
The unchanged assistant, run six times, passed 174, 184, 181, 180, 174 and 179 tests: 89.2% to 94.4%, 91.6% on average. Nothing changed between those runs. Models just don't answer exactly the same way every time, so the score wobbles by about 5 points on its own, like a bathroom scale that reads a little differently every time you step on it.
49 of the 195 tests passed in some runs and failed in others. These are flaky tests.
Planted changes
Then the lab changed the assistant six ways and ran each version three times:
| Change | Pass rate | vs. unchanged |
|---|---|---|
| Unchanged (6 runs) | 91.6% (89.2–94.4%) | |
| Older, cheaper model (gpt-4o-mini) | 96.4% | +4.8 |
| 3% of the index scrambled | 89.7% | −1.9 |
| 10% of the index scrambled | 84.8% | −6.8 |
| Search takes 1 passage, not 3 | 80.2% | −11.5 |
| 30% of the index scrambled | 76.2% | −15.4 |
| A concise prompt that drops citations | 22.9% | −68.7 |
Two lessons before any alarm rule. Not every change is a drop: the older model scored higher. And a small drop hides in the wobble: 1.9 points sits inside the unchanged runs' own range. The real breakages cost 7 to 69 points.
Three alarm rules
An alarm when nothing changed is a false alarm. Each rule was replayed 200 times over 60 nights of the unchanged assistant:
| Rule (nightly, all 195 tests) | False alarms in 60 nights | Caught the 2-point change within a week |
|---|---|---|
| Score more than 3 points below its usual | 2.3 | 87% |
| Paired test | 9.0 | 96% |
| Paired test, flaky tests left out | 37.4 | 100% |
| Each test vs. its own pass rate | 0.02 (4 in 200 replays) | 8% |
All four caught every real breakage (10% and 30% scrambled, one passage, no citations) in every replay, with a median delay of 11 hours. The difference is how often they cry wolf.
The paired test (McNemar's test, the one used to compare two methods in chapter 54) sounds like the smarter rule, because it looks at each test on its own:
- First it builds a reference: what each test did in most of the three early runs.
- Each night, it checks every test against its reference: did it go down (pass to fail) or up (fail to pass)?
- If far more went down than up, more than chance would give (p < 0.01), it raises the alarm.
Pick a night and see what each rule does. Start with unchanged run 5, then tick "leave out":
| Rule | Tonight | Alarm? |
|---|---|---|
| Score more than 3 points below its usual 92.1% | 89.2% | no |
| Paired test: more down than up, p < 0.01 | 15 vs 3, p = 0.008 | yes |
| Each test vs its own pass rate: more than 25.7 failures (expected 15.3) | 21 failed | no |
Nothing changed tonight, so any alarm here is a false alarm. Every test the reference calls a pass can only go down; only the 9 it calls a fail can go up.
Why the paired test cried wolf
The reference turns every test into a sure pass or a sure fail: 186 sure passes and 9 sure fails. But a test that passed all three early runs still fails now and then: about one later run in 18 (5.7%). So on any night, many more tests can slip down than climb up, with nothing changed.
On unchanged run 5, the worst of the three later runs: 15 down, 3 up, p = 0.0075. The paired test called that worse and raised the alarm.
Now leave out the 25 tests that flipped in the three early runs. What's left did the same thing in all three runs, and 164 of the 170 passed. Almost all of them can only go one way: down. Run 5 becomes 14 to 1, and run 6, 8 to 0, fires too. Over 60 nights, 37 false alarms. And the "stable" tests weren't: 24 of the 170 flipped in a later run.
It's like picking the students who aced three quizzes in a row. On the fourth, some slip, not because they got worse, but because luck helped pick them. That's called regression to the mean. It has nothing to do with regression testing.
Pick the aces from runs 1–3, then watch them on the unchanged runs 4–6:
These 164 tests aced all three early runs: 100% by construction. That is how they were picked.
McNemar's test itself isn't the problem. It fits when both sides are single runs measured the same way: two versions, each run once on the same tests. The bias comes from treating a majority vote of noisy runs as the truth: that removes the noise from one side only.
The fix: compare each test with itself
Give each test its own pass rate instead of a sure pass or fail. Three runs is few, so each rate is pulled toward the suite's average: (passes + 3 × average) / 6.
| Passed in runs 1–3 | Its pass rate |
|---|---|
| 3 of 3 | 96% |
| 2 of 3 | 79% |
| 0 of 3 | 46% |
A test with a perfect record still gets a small chance to fail; a flaky test gets a bigger one. Add up each test's chance to fail and you get the failures to expect on a normal night: about 15. The alarm fires only well above that: past expected + 3 standard deviations, about 26 failed tests.
failed tests of 195 · dashed: expected on a normal run (15.3) · red: the alarm line
Lower the line and the 2-point change starts to cross it, but so do unchanged runs. At 1 SD (18.8 failures), two of the 2-point change’s runs cross (19 and 24 failed), and so does unchanged run 5 (21). The real breakages sit far past any sensible line. The runs are real; the lab’s false-alarm counts come from replaying 60 nights mixed from runs 4–6, 200 times.
- The unchanged runs 4–6 failed 15, 21 and 16: all below the line.
- Every run of the real breakages is above it: 29–31 (10% scrambled), 37–41 (one passage), 46–47 (30% scrambled), 149–151 (no citations).
- Replayed over two months: 4 false alarms in 200 replays. It still caught every real breakage, with a median delay of 11 hours.
The price: the 2-point change failed 19, 24 and 17 tests, under the line too. This rule caught it only 8% of the time within a week; the older rules caught it most of the time, the same rules that fire on nothing. That's what not crying wolf costs.
What the alarm says
An alarm should also say what broke. The agent lists the tests that newly fail (passed in the baseline, fail now), grouped by how they fail:
| Change | Newly failing | How they fail |
|---|---|---|
| Prompt drops citations | 141 | all 141 "no citation" |
| 30% of the index scrambled | 39 | 25 refused, 7 no citation, 7 wrong |
| Search takes 1 passage | 34 | 18 refused, 13 no citation, 3 wrong |
"No citation" across every article points straight at the prompt. But the scrambled index and one-passage search look alike: mostly refusals, spread over many articles. Telling those two apart takes a look at the index itself, which is chapter 60.
Also in the lab
These parts of script 03 aren't in the video. From the lab's README and result files (the same October 2026 run):
- Running more often. Every 6 hours with the per-test rule: 0.1 false alarms in 60 days, real breakages caught in a median 3 hours, and the 2-point change 30% of the time within a week, at $0.22 a day instead of $0.05.
- Small hourly samples. Every hour on 20 random tests, the 3-point threshold false-alarmed 369 times in 60 days: 20 tests are far noisier than 195.
- CUSUM (cumulative sum) adds up "failures beyond expected" over time and alarms past a level. Set to one false alarm per 60 days on runs 1–3, it gave 4.8 on runs 4–6: noise estimated from three runs is too optimistic.
- The 2-point change, alarmed. 3% scrambled: 12 newly failing in its first run, 6 no citation, 4 refused, 2 wrong. The older model: 3 newly failing and 3 newly passing.
- Building it. The lab's first per-test rates used (passes + 1) / (runs + 2), which puts a 3-of-3 test at 80% and expected twice the real failures; it caught nothing. Pulling toward the suite's average keeps the expected count right.
What to do
- Measure the noise first. Run the unchanged system several times and look at the spread before you decide what a drop is.
- Keep the flaky tests in. Leaving them out doesn't remove noise; it picks tests that can only get worse.
- Compare each test with its own pass rate, pulled toward the average when you have few runs, and alarm on more failures than expected.
- Set the rule on some runs and check its false alarms on others.
- Decide what size of drop you need to catch. Smaller drops need more tests or more runs, not a twitchier line.
- Make the alarm say what broke: the newly failing tests, and how they fail.
Caveats
- Simulated nights. There are 6 real runs of the unchanged assistant and 3 per change. Each two-month replay mixes those runs test by test, which assumes a test's result one night doesn't depend on another's.
- Few runs. Each test's rate comes from three runs, and the false alarms from three more. With more baseline runs, the rates (and the paired test's reference) would be better.
- An AI grader. A pass is
gpt-5.4-minisaying the answer is right; the grader's own wobble is part of the noise measured here. - One suite, one assistant. 195 tests and a made-up course site. Other systems wobble more or less; measure yours.
- Planted breakages. Real breakages may be gradual, or hit a few tests hard; a rule that sums failures across the suite sees those later.
The checklist
- Run the unchanged system several times and record the pass-rate range and the flaky tests.
- Never turn a majority vote of noisy runs into a fixed pass/fail reference for a paired test.
- Give each test a pass rate, and compute the failures to expect on a normal night.
- Set the alarm line from calibration runs, and count false alarms on held-out runs.
- Replay the rule against planted breakages to see what it catches and how fast.
- List newly failing tests with how they fail in every alarm.
- Write down the smallest drop the rule can catch, so nobody assumes it catches everything.
Practice: three alarm rules in code
Build the paired test's reference, count down and up, compute McNemar's p-value, then the per-test pass rates and the alarm line. The tests use the real pass/fail results of all 24 runs and expect the lab's numbers: 186 sure passes, 25 flaky, 15 vs 3 on run 5 (14 vs 1 without the flaky tests), one slip in 18, 96/79/46%, about 15 expected and a line at 25.7, quiet on unchanged nights and loud on every real breakage.
Quiz
1.Six runs of the unchanged assistant passed 174 to 184 of the 195 tests. What does that mean for an alarm?
2.Swapping in the older, cheaper gpt-4o-mini model scored 4.8 points higher. What should a drop alarm do?
3.Why does the paired test fire on an unchanged night?
4.Leaving out the 25 tests that flipped in the three early runs took false alarms from 9 to 37. Why?
5.How does the per-test rule decide whether tonight is bad?
6.What does the per-test rule give up for almost no false alarms?
Check your understanding
Try each question before opening its answer.
Your nightly suite dropped 2 points. What do you check before paging anyone?
The unchanged system's own run-to-run spread, and which tests flipped. Here the unchanged assistant ranged from 89.2% to 94.4%, so 2 points on 195 tests (about four tests) is well inside the noise.
Why can a paired test against a majority-vote reference fire when nothing changed?
The reference calls 186 tests sure passes and 9 sure fails, but a test that passed three early runs still fails about one later run in 18. Down can outnumber up by chance: 15 to 3 on unchanged run 5, p = 0.0075, under the 0.01 cutoff.
Why did leaving out the flaky tests make the false alarms go up, from 9 to 37?
The tests kept were picked for doing the same thing three times, and 164 of 170 had passed every time. Picked for passing, they can mostly only slip: 14 down, 1 up on run 5. That's regression to the mean.
How does comparing each test with its own pass rate avoid that?
No test is treated as a sure thing: a 3-of-3 test is expected to fail 4% of the time, a 2-of-3 test 21%. Summed up, a normal night is expected to fail about 15 tests, and the alarm waits for more than about 26. Unchanged runs failed 15, 21 and 16.
What does the per-test rule miss, and what would you do about it?
Small drops: the 2-point change failed 19, 24 and 17 tests, under the line, and was caught 8% of the time within a week. If drops that size matter, run more tests or more often (every 6 hours caught it 30% of the time), rather than lowering the line into the noise.
Two alarms both say "about 35 tests newly failing, mostly refused, spread across many articles". What can you conclude?
Search is probably returning the wrong passages, but not why. In the lab, a scrambled index and search taking one passage instead of three looked just like that; telling them apart needs a look at the index itself. A wave of "no citation", by contrast, points straight at the prompt.
Next up: Chapter 60, self-healing RAG: the QA agent says search broke, so the system checks its own index and repairs it. The repair was broken too.