ealeng

Episode 57 of 61 · Self-improving systems

Auto-generated tests: who checks the checker?

An assistant writes its own tests from what learners ask, and an AI reviewer approves them: 160 of 161. It agreed with the answer key 97% of the time, but almost every test was right, so approving everything would agree 96%. Beyond luck, kappa 0.28. Of the 3 real writer mistakes among the 6 tests the key called wrong, the reviewer caught 1. On the way: where to draw the 'is it new?' line, why the generator must remember every candidate (39% less review), coverage over suite size, and tests that go stale.

Lab 18 · Autonomous Systems11 min read
Video transcript8:43

0:00Cold open

0:01

My system now writes its own tests, from what learners ask.

0:05

An AI reviewer checks each test. It approved a hundred and sixty of a hundred and sixty-one.

0:13

It agreed with my answer key ninety-seven percent of the time. The key is a reference answer for every question, and a model that grades each test against it.

0:24

Then I read the tests my key called wrong.

0:28

Three were real mistakes, among the ones I read. The reviewer let two of them in.

0:34

So what did ninety-seven percent measure?

0:38Intro

0:39

Hands-on AI engineering: autonomous AI, part one.

0:44

Today: tests that grow from real usage. And who checks them.

0:49Meet Nadia

0:51

I’m Nadia, an AI engineer at Quill Academy, a made-up online course site.

0:57

Our assistant answers learners’ questions from seven short articles. You may know it from the observability series.

1:05

Now I want it to run more on its own. Step one: tests that grow from what learners actually ask.

1:13

A test is a question, plus the answer we expect.

1:18

All our tests together are the suite. It runs on every change, to catch anything that breaks.

1:25

Here’s the plan. A message comes in. Is it asking something new?

1:30

If so, an AI writes a test for it. A reviewer approves it, and it joins the suite.

1:37

The assistant runs on a small model. A bigger model writes and reviews the tests.

1:44

To check all this, I replayed six weeks: about a thousand messages, written by a model to sound like learners.

1:52

Every answer is a real, recorded model call.

1:5701 · Is it new?

1:59

First: is a message new, or does a test already cover it?

2:04

Think of a librarian with a box of index cards.

2:08

For each new question, she looks for a card that means the same thing, even in different words.

2:15

A computer does this by turning meaning into a list of numbers, called an embedding.

2:21

Then it measures how close two meanings are. That’s the similarity: zero is unrelated, one is the same meaning.

2:29

This message scores point nine six against an existing test. Almost the same words. A repeat.

2:37

This one, how to say good morning in French, scores point zero nine. It’s new.

2:43

It’s off-topic, so it makes a good test of the assistant saying “I don’t know”.

2:49

I drew the line at point seven. Below it, a message counts as new.

2:5602 · The line

2:57

Where exactly to draw that line is a trade.

3:01

At point seven, it spotted most repeats: seventy-eight percent.

3:07

It called ninety-three percent of new questions new. The other seven percent got no test.

3:14

Raise the line to point eight, and all of them count as new.

3:19

But fewer repeats get spotted. A hundred and fifty-one more messages look new, and go on to the test writer.

3:27

Most of those are repeats. Each one is a test the reviewer reads for nothing.

3:33

Draw the line too low instead, and a new question gets no test at all.

3:4003 · Remember everything

3:41

Next question: compare each new message with what?

3:46

To test just this, I pretend the writer and the reviewer are perfect.

3:51

Option one: compare with nothing. Then a person reviews every real question: nine hundred eighty-eight in six weeks.

4:00

Option two: compare with the approved tests only. Two hundred sixty-four.

4:06

Why still so many? New tests are reviewed once a week, at the end of the week.

4:12

In week six, on Monday, a learner asked why full fine-tuning is expensive. A test was written, and it waited for the weekly review.

4:22

On Wednesday, someone asked why full fine-tuning costs so much. Not an approved test yet, so it looked new. Another test.

4:31

Option three: also compare with every earlier message it judged new, called a candidate, whether approved, waiting or rejected. A hundred sixty-two.

4:43

That’s thirty-nine percent less review than option two, and it covers the same questions. Seven questions slip under the line in both. That’s the trade from before.

4:5504 · Coverage, not size

4:57

Is a bigger suite a better one? Look at what the tests cover.

5:01

Coverage here means the share of each week’s messages that a test already covers.

5:08

In week one, it was thirty-six percent. By week two, eighty-six.

5:14

Why so fast? The popular questions come up in week one, so they get tests first. And they make up most of the later messages.

5:23

In week four, two new articles launched. Coverage fell to sixty-five. A week later, it was back.

5:31

Meanwhile, the suite kept growing, to about two hundred tests.

5:36

So count the messages covered, not the tests.

5:4105 · The expected answer

5:42

Each test needs an expected answer. Who writes it?

5:47

The easy way: copy what the assistant answered in production.

5:52

Here’s the catch. A learner asked for the fundamental unit of a transformer. The assistant refused to answer.

6:01

But the articles do answer it: the attention head.

6:05

So the copied test expects a refusal. Fix the assistant, and this test fails the fix.

6:13

The other way: write the expected answer from the articles.

6:18

Written from the articles, a hundred fifty-five of a hundred sixty-two tests were right. Copied, a hundred fifty.

6:2706 · The reviewer

6:29

Back to the reviewer, and its ninety-seven percent.

6:33

Here’s why that number is weaker than it sounds. Almost every test was right.

6:39

So a lazy reviewer that approves everything would agree ninety-six percent of the time.

6:46

A score called kappa takes out the agreement you’d get by luck.

6:51

One means perfect. Zero means no better than luck. The reviewer got point two eight.

6:58

So I read the six tests my key called wrong. The reviewer had let five of them in.

7:04

My key isn’t perfect either: models wrote its reference answers, and a model grades against them. Two of its answers were too narrow to grade against, like the single word “noisy”. One test is arguable.

7:19

Three were the writer’s real mistakes: answers the articles don’t support. How many did the reviewer catch?

7:28

One. It let the other two in.

7:3207 · Stale tests

7:34

One more way tests go wrong. On day twenty-eight, the fine-tuning article was revised.

7:41

Five tests had been written before that, about the parts it changed.

7:46

Four of them now expect the old answer.

7:50

Two were starting tests. Two the system wrote itself.

7:55

A test is a claim about the articles, on the day it was written.

8:01Back to Nadia

8:03

So, what did ninety-seven percent measure? Mostly that almost every test was right.

8:09

Now the system compares each message with every candidate. And I count the messages covered, not the tests.

8:17

Expected answers come from the articles. And a person reviews the new tests.

8:23

When an article changes, its tests get checked again.

8:27

Next time: can the assistant tell which of its own answers are wrong?

8:34Summary

8:35

Tests can grow on their own.

8:38

Checking them is still a person’s job.Nadia: Check the checker.

Key takeaways

  • ✓A test is a question plus the answer you expect. To grow the suite from real usage, compare each message with the existing tests by meaning (embedding similarity, 0 unrelated to 1 the same meaning). Below a line, it's new and an AI writes a test for it. The lab's line, 0.70, was chosen on weeks 1–2 only.
  • ✓Where you draw the line is a trade. At 0.70, 78% of repeats were spotted and 93% of new questions were called new; the other 7% got no test. At 0.80, every new question was caught, but only 44% of repeats: 151 more messages went to the writer, most of them copies of existing tests.
  • ✓Compare each message with every candidate, not just approved tests. With approved tests only, a question asked again before the weekly review looks new and gets a second test: 264 tests to review in six weeks. Remembering every candidate (approved, waiting or rejected): 162, 39% less, for the same 137 questions covered.
  • ✓Count the messages covered, not the tests. Coverage of each week's messages went from 36% in week 1 to 86% in week 2, because popular questions come first. It fell to 65% when two new articles launched in week 4 and was back to 86% a week later, while the suite grew to about 200 tests.
  • ✓Write the expected answer from the documents, not by copying production. Copied answers turn the assistant's mistakes into tests: it refused 'what is the fundamental unit of a transformer', though the articles say the attention head, so that test would fail the fix. From the articles 155 of 162 tests were right; copied, 150.
  • ✓97% agreement can mean little when almost everything is right. Kappa takes out the agreement you'd get by luck: the reviewer scored 0.28. Reading the 6 tests the key called wrong: 3 were the writer's real mistakes, and the reviewer let 2 of them in. And tests go stale: after one article was revised, 4 of the 5 tests written earlier about the changed parts expected the old answer.

The assistant from the observability chapters (40–43) now writes its own tests: when learners ask something new, an AI drafts a test for it, and another AI reviews it. The reviewer approved 160 of 161 and agreed with the answer key 97% of the time. This chapter asks what that 97% measured, and goes through the decisions on the way: what counts as new, what to compare with, what to count, and who writes the expected answer.

The source is Lab 18 (Autonomous Systems), script 01_test_generator.py, recorded in October 2026; the video uses that run's recorded results, no new calls, and its numbers match the lab README. Quill Academy is a made-up online course site; its assistant answers from seven short articles. Six weeks of traffic, about a thousand messages, were written by a model to sound like learners, with changes planted on purpose: two new articles in week 4 and a revised one on day 28. Every answer is a real recorded model call: gpt-5.4-nano answers, gpt-5.4-mini writes and reviews the tests. This is the first chapter on self-improving systems.

The plan

A test is a question plus the answer we expect. All the tests together are the suite, which runs on every change to catch anything that breaks. The suite starts with 40 tests, taken from the observability lab's questions. Then, for every learner message:

  1. Is it new? Compare it with the tests by meaning.
  2. If so, write a test: an AI drafts the question and the expected answer.
  3. Review it: once a week, a reviewer approves or rejects each new test.
  4. Approved tests join the suite.

Each step can go wrong in its own way, and the lab replays six weeks to measure each one.

Is it new?

A computer compares meanings by turning text into a list of numbers, an embedding, and measuring how close two of them are: the similarity, 0 for unrelated and 1 for the same meaning. Each message is compared with its closest test. Above the line, it's a repeat; below, it's new.

"hey, what's the difference between HNSW's M and efConstruction parameters" scores 0.96 against an existing test: a repeat. "how do you say good morning in french" scores 0.09: new, and off-topic, which makes a good test of the assistant saying "I don't know".

Of 988 real messages (chatter like "thanks!" left out), 316 ask something a starting test covers and 672 don't. Similarity ranks them well (AUROC 0.952: a random covered message scores higher than a random new one 95% of the time), but no line separates them perfectly:

Try it · Is it new? Move the lineLab 18 · script 01 · 988 real messages, 6 weeks

Each message is compared with the closest test by meaning (similarity: 0 unrelated, 1 the same meaning). Below the line, it counts as new and goes on to the test writer.

0.500.900.70
Repeats spotted (of 316)
78%
New called new (of 672)
93%
Sent to the test writer
696

95% intervals: repeats (73%–82%), new (91%–95%). This is the line the lab chose, on weeks 1–2 only.

Message

“hey, what's the difference between HNSW's M and efConstruction parameters”

Closest test: What is the difference between HNSW's M and efConstruction parameters?

similarity 0.96 → repeat: skip

Message

“how do you say good morning in french”

Closest test: In transformers, how does multi-head attention help the model?

similarity 0.09 → new: write a test

At 0.70, 7% of new questions get no test. Raise the line and fewer repeats are spotted.

The lab chose 0.70 on weeks 1–2 only. There, 78% of repeats were spotted and 93% of new questions were called new; the other 7% got no test. At 0.80, every new question counts as new, but only 44% of repeats are spotted: 847 messages go to the writer instead of 696. Of the 151 extra, 108 are repeats, each a test the reviewer reads for nothing.

Similarity misses in two directions, which is why no line is perfect. "rag meaning" scores only 0.46 against the test "What is Retrieval-Augmented Generation (RAG)?": the same question in very few words. And "can you explain how the react pattern works" scores 0.80 against "what is the ReAct pattern?": nearly the same words, but one asks how and the other what.

Compare with what?

Next: compare each new message with what? To test just this, the lab pretends the writer and the reviewer are perfect, and reviews at the end of each week.

  • Nothing. Every real message becomes a test for a person to review: 988 in six weeks.
  • Approved tests only. 264. Why still so many? In week 6, on Monday, a learner asked why full fine-tuning is expensive, and a test was written. It waited for the weekly review. On Wednesday someone asked why full fine-tuning costs so much. That wasn't an approved test yet, so it looked new, and got another test.
  • Every candidate. Also compare with every earlier message judged new (a candidate), whether approved, waiting or rejected: 162.
Try it · Compare each message with what?Lab 18 · script 01 · perfect writer and reviewer

Also compare with every message already judged new: approved, waiting or rejected.

WeekTests to reviewSuite at week's endMessages covered
1
58
9836%
2
28
12686%
3
13
13993%
4
31
17065%
5
21
19186%
6
11
20286%
Reviewed in 6 weeks
162
Tests for a question already covered
65
Questions covered
137

Week 1 starts from the 40 starting tests. Week 4: two new articles launched, so coverage dropped. “Every candidate” needs 39% less review than “approved only” for the same 137 questions covered. Comparing with nothing covers 7 more, because it skips nothing; the other two miss the same few that slip under the line.

Remembering every candidate cut review by 39% against "approved only", and covered the same 137 questions. The 7 that "nothing" also covers are the new questions that slip under the line in both: the trade from the previous section. In the lab's first version, the candidate list even changed with the reviewer, because a rejected test came back the next week. Remembering every candidate fixed that too.

Coverage, not size

Is a bigger suite a better one? Look at what the tests cover: the share of each week's messages that a test already covered.

Week 1 2 3 4 5 6
Messages covered 36% 86% 93% 65% 86% 86%
Suite size 98 126 139 170 191 202

Coverage jumped in one week because the popular questions come up in week 1, so they get tests first, and they make up most of the later messages. In week 4, two new articles launched and coverage fell to 65%; a week later it was back. The suite kept growing the whole time. Comparing with nothing grew it to 1,028 tests, 884 of them for questions already covered. Count the messages covered, not the tests.

Who writes the expected answer

Each test needs an expected answer. The easy way is to copy what the assistant answered in production. The catch: a learner asked "what is the fundamental unit of a transformer", and the assistant said it wasn't in the documents. The articles do answer it: the attention head. So the copied test expects a refusal. Fix the assistant, and this test fails the fix.

Expected answer Right tests (of 162 real requests) What the test then checks
Copied from production 150 that the system keeps doing what it did, mistakes included
Written from the articles 155 that the system says what the articles say

The writer also filters out messages that aren't worth a test. It dropped all 10 chatter messages among the 172 candidates, and 1 of the 162 real requests.

The reviewer

Back to the reviewer (gpt-5.4-mini) and its 97%. It approved 160 of the 161 tests the writer kept. The answer key (a reference answer for every question, with a model grading each test against it) says 155 are right and 6 wrong.

That's why 97% is weaker than it sounds: almost every test was right, so a lazy reviewer that approves everything would agree 96% of the time. Kappa takes out the agreement you'd get by luck: 1 is perfect, 0 no better than luck. The reviewer got 0.28. Try it:

Try it · What did 97% measure?Lab 18 · script 01 · gpt-5.4-mini reviewing 161 tests

155 tests are right by the answer key and 6 are wrong. Choose what the reviewer does with each wrong one, and how many right ones it wrongly rejects.

  • “i'm working on prompt design for an llm app and need to understand what prompt sensitivity means”
  • “how does product quantiztion compress vectors”
  • “what's a good way to assess whether a rag response stays faithful to the source docs”
  • “how does pq shrink high-dimensional vectors”
  • “im building a model eval dashboard and want to know what evaluation results look like in llm evaluation”
  • “hey how do i lock down an mcp server”
0
Agreement with the key
97%
Beyond luck (kappa)
0.28
Real mistakes let in (of 3)
?

Kappa compares agreement with what you'd get by luck from how often each side says yes: 1 is perfect, 0 no better than luck. Approving everything agrees 96% of the time and scores 0. The real reviewer: 156 of 161 (97%), kappa 0.28.

The lab then read the 6 tests the key called wrong; the reviewer had let 5 of them in. The key isn't perfect either: models wrote its reference answers, and a model grades against them. Two of its answers were too narrow to grade against, like the single word "Noisy." for "what do evaluation results look like". One test is arguable: the articles partly answer it. Three were the writer's real mistakes, answers the articles don't support: two about product quantization from the writer's own knowledge, and one about locking down an MCP server pieced together from unrelated passages. The reviewer caught one. It let the other two in.

The split into real mistakes, narrow keys and arguable is a reading by hand (the lab's and the video's), not a measured label.

Tests go stale

On day 28, the fine-tuning article was revised: LoRA now goes on all linear layers, and a few hundred examples are enough. Five tests in the final suite had been written before that, about the parts it changed. Graded against the new article, four of them now expect the old answer:

Test Written Still right?
What three situations make fine-tuning most valuable? starting test no: expects "thousands of labeled examples"
What does PEFT do instead of updating all model weights? starting test no: expects attention layers only
How does PEFT with LoRA reduce trainable parameters…? generated, day 4 no: attention layers only
Why do PEFT LoRA trainable parameters still work well? generated, day 9 no: attention layers only
What is the difference between PEFT and full fine-tuning? generated, day 11 yes

Two were starting tests; two the system wrote itself. Stale, they fail the correct, updated assistant. A test is a claim about the articles, on the day it was written.

Also in the lab

From the lab's README (its own run, October 2026), beyond the video:

  • The writer explained instead of declining. Asked to write "(not in the documents)" when the passages didn't answer, it wrote "The documents do not specify…" paragraphs, which the judge graded as wrong. The fix was a separate answered: true/false field, with code, not the model, writing the decline: right tests went from 86% to 96%.
  • The writer threw away good tests. Told to drop messages that aren't about the docs, it dropped off-topic and unanswerable requests too, which make good refusal tests. The prompt now drops only greetings, thanks, complaints and keyboard noise: 1 real request dropped instead of 10.
  • What it doesn't include. The "person" in the review queue is the answer key, a perfect reviewer; real reviewers are slower and sometimes wrong. Every message is a single turn.
  • Cost. Script 01 costs about 60 cents the first time (including the production answers that later scripts reuse), then runs free from the cache.

What to do

  • Pick the "is it new?" line on labeled messages, and know both of its mistakes: repeats that become tests, and new questions that get none.
  • Compare each message with every candidate, approved, waiting or rejected, not just approved tests.
  • Rank the review queue by traffic, and track the share of messages covered, not suite size.
  • Write expected answers from the documents, not from production answers.
  • Don't trust a reviewer's agreement alone. Check kappa, and read the disagreements by hand.
  • Re-check tests when a document changes, starting with the ones about the changed parts.

Caveats

  • Made-up site, model-written traffic. The messages were written by a model to sound like learners, with planted changes. Real traffic is messier.
  • A perfect writer and reviewer in the memory comparison, so it measures only what each memory sends to review.
  • The answer key is models too. Its reference answers were written by models and a model grades against them; 2 of the 6 "wrong" tests were the key's fault.
  • Six tests is a small sample. "Caught 1 of 3 real mistakes" comes from reading six tests by hand.
  • One line, chosen on two weeks. A different corpus or embedding model needs its own line.

The checklist

  1. Label a few hundred messages (covered or new) and choose the line on them.
  2. Store every candidate with its status, and compare new messages with all of them.
  3. Report weekly coverage of real messages, and the uncovered questions ranked by traffic.
  4. Generate expected answers from the documents, with code writing any "not in the documents" decline.
  5. Measure the reviewer with kappa against a labeled sample, and read what it approves.
  6. Link each test to the documents it came from, and re-check those tests when a document changes.

Practice: the generator's checks in code

Draw the line on the lab's 988 similarities, count how much review each kind of memory costs on a small replay, write Cohen's kappa, and list the tests to re-check after the revision. The tests expect the lab's numbers: 246, 626 and 696 at 0.70; 847 at 0.80; 156 agreements and kappa 0.28; and the five fine-tuning tests written before day 28.

Try it · Practice in PythonRuns in your browser · ⌘/Ctrl + Enter to run
testgen_practice.py52 lines

Quiz

Try it · Check your understanding0 of 6 answered
  1. 1.A message scores 0.09 similarity against its closest test, with the line at 0.70. What happens?

  2. 2.You raise the line from 0.70 to 0.80. What changes?

  3. 3.The generator compares each message only with approved tests, reviewed weekly. Why does that cost more review?

  4. 4.Why measure the share of messages covered rather than the number of tests?

  5. 5.Why not copy the assistant's production answer as the expected answer?

  6. 6.The reviewer agreed with the answer key 97% of the time. What does kappa 0.28 add?

Check your understanding

Try each question before opening its answer.

How does the system decide whether a learner's message needs a new test, and what can go wrong?

It compares the message with its closest test by meaning (embedding similarity) and calls it new below a line, 0.70 here, chosen on labeled messages from weeks 1–2. Short phrasings of a covered question can score low ("rag meaning", 0.46), so they become duplicate tests; different questions in similar words can score high ("how does ReAct work" vs. "what is ReAct", 0.80), so they get no test.

Why should the generator remember rejected and waiting candidates, not just approved tests?

Otherwise a question asked again before the weekly review looks new and gets another test, and rejected ones come back. Remembering every candidate cut six weeks of review from 264 to 162 (39%) for the same 137 questions covered.

Your suite grew from 40 to 200 tests. Is that good news?

Not by itself. Look at the share of real messages the tests cover: here it went 36% to 86% in a week, then mostly held, with a dip to 65% when new articles launched. Comparing with nothing built 1,028 tests, mostly duplicates. Check also that the tests are right and still right.

Should a generated test's expected answer come from the production answer?

No, or only after a person checks it. Copying turns production mistakes into tests that reward them: a refusal of a question the articles answer became a test that fails the fix. From the articles, 155 of 162 tests were right; copied, 150.

A reviewer agrees with your key 97% of the time. Why might that mean little?

If almost every test is right, approving everything already agrees 96% of the time. Kappa removes that luck: 0.28 here. Reading the six disagreements showed it caught 1 of 3 real writer mistakes.

A document is revised. What happens to its tests, and what do you do?

Tests written before the change still expect the old answer, so they fail the correct, updated system: 4 of the 5 here. Link tests to their source documents, and when one changes, re-check or rewrite its tests.

Next up: Chapter 58 asks whether the assistant can tell which of its own answers are wrong: can a model check its own answers?

Learning something useful?

New labs, articles, and videos on evaluating and testing AI systems come out regularly. Follow along so you don't miss the next one.