IamBishal

Module 1Lesson 1 of 2

1.1 Why reading outputs isn't an eval

Shows from a recorded run why five random drafts can look fine while a missed escalation (G26) sits in the full 40, and why a five-draft sample includes any one case only 12.5% of the time. Then sets the drafter's contract, derives the four-part failure taxonomy through error analysis, rewrites each type as a PASS/FAIL criterion and picks a code, LLM judge or human grader for each.

You changed a prompt. You ran it on a few tickets, read the replies, and they looked good. So you shipped it. This lesson is about why that check can't tell you whether the change helped, and what to do instead. It sets out the feature this tutorial tests, the four ways it fails, and the checklist that lessons 2 to 5 close.

There is one small program to run, read_five.py. It replays a recorded run, so you need no API key.

By the end you will be able to:

  • explain why reading a few drafts can't tell you whether a change helped, and work out how often a sample even contains a given failure;
  • state the drafter's contract and say where in its output each kind of failure shows up;
  • read real drafts and file each failure under one of four types;
  • write a failure type as a criterion with a PASS/FAIL verdict;
  • pick code, an LLM judge or a person to grade each criterion, and say why.

Before you start. You need Python 3.12 and uv. The series uses the anthropic Python SDK 2.12.0. To follow along:

bash
git clone https://github.com/bishal-saha/tutorials-code.git
cd tutorials-code/build-an-llm-eval-suite/01-foundations/01-why-reading-outputs-isnt-an-eval
uv sync
uv run python read_five.py
uv run pytest tests        # 4 passed

The script's first line of output is Five drafts, picked at random:. If uv sync fails, check python3 --version (3.12 or newer) and that uv --version works; install uv from its documentation if it doesn't.

The companion folder holds read_five.py, the golden set and a recorded run of the drafter, with 4 tests. Every number below comes from that folder. The recorded run was made on 2026-11-21 with claude-sonnet-5-5.

1. The feature under test

Helpline is a made-up support desk. Its support team gets a draft reply for every new ticket, written by one Claude call. This tutorial calls that call the drafter.

The drafter's contract is small:

  • In: one ticket (the customer's plan, a subject and a body) and Helpline's knowledge base of 15 articles, KB-101 to KB-115.
  • Out: a structured draft with three fields: reply, the text a person will review; cited_articles, the knowledge-base articles the reply relies on; and escalate, whether a person must take over.

Here is a real draft from the recorded run. The customer wrote that the docs say a reset link lasts 24 hours, but theirs stopped working after an hour:

json
{
  "reply": "Thanks for reaching out. Nothing is broken, but our documentation on this point is not what you saw: password reset links expire after 30 minutes, not 24 hours, so a link that stopped working after an hour was behaving as designed. To fix it, just request a new reset link and use it within 30 minutes. ...",
  "cited_articles": ["KB-108"],
  "escalate": false
}

That is a good draft. KB-108 says reset links expire after 30 minutes, and the reply corrects the customer's number instead of agreeing with it.

2. Five drafts that look fine

read_five.py does what most people do after a prompt change. It picks five drafts at random from a run over 40 tickets and prints them:

text
Five drafts, picked at random:

[G09] How do we delete our workspace?
  escalate=False  cites=['KB-111']
  Hi,  Sorry to hear the project is wrapping up. An admin can delete the whole workspace by going to Admin > Workspace > Delete.  Please note that deleted data is...

[G37] SCIM provisioning
  escalate=True  cites=['KB-112']
  Thanks for reaching out. Our knowledge base doesn't cover SCIM provisioning, so I can't confirm whether it's supported or how to set it up. I've passed your que...

[G05] Codes by SMS arrive late
  escalate=False  cites=['KB-105']
  Yes, you can switch to an authenticator app, which avoids SMS delays entirely. Go to Profile > Security, choose Authenticator app, and scan the QR code with you...

[G17] Reset link expired early
  escalate=False  cites=['KB-108']
  Thanks for reaching out. Nothing is broken, but our documentation on this point is not what you saw: password reset links expire after 30 minutes, not 24 hours,...

[G08] New password rejected
  escalate=False  cites=['KB-108']
  Thanks for reaching out. Since you've confirmed you don't use SSO, here's what to check: first, make sure caps lock is off when you type the new password. Also ...

They do look fine, and you'd ship. In fact G37's full reply carries a sentence no article supports, past where the preview cuts off; this lesson comes back to it. Even reading the whole reply, you'd need the knowledge base open to see it. Then the script checks every one of the 40 drafts against what each ticket should have produced:

text
Checked against the expected escalation for all 40 cases: ['G26']
Chance that reading 5 random drafts shows any of them: 12.5%

One draft out of 40 made the wrong call. With one failure in the run, five random drafts include it one time in eight. Each of the 40 drafts is equally likely to be among the five picked, so the chance that a particular one is picked is 5/40 = 1/8. Seven times in eight a careful reader sees nothing wrong. The arithmetic is short:

With one failure in 40, a five-draft sample includes it only one time in eight.
python
def chance_to_see(failures: int, total: int, read: int) -> float:
    """Probability that `read` drafts picked at random include at least one failure."""
    return 1 - comb(total - failures, read) / comb(total, read)

Reading outputs has a second problem, and it's worse. Even if you happen to read G26, it doesn't look broken.

3. G26: a good reply that breaks the policy

The ticket: an Enterprise customer says the API was down for three hours last Tuesday and expects a service credit on this month's invoice. The draft:

json
{
  "reply": "Hello, and we're sorry about the disruption you experienced last Tuesday. Service credits are defined in the Enterprise SLA. If monthly uptime falls below 99.9%, the account owner can request a credit under Billing > SLA claims within 30 days of the incident. ... Please note that support agents can't grant or promise credits, so we can't confirm that a credit will be applied to this month's invoice. ...",
  "cited_articles": ["KB-109", "KB-115"],
  "escalate": false
}

Every fact in it comes from KB-109, and it sends the customer down the self-serve SLA claim path. It promises nothing. A reader would approve it. But Helpline's escalation policy, which the golden set in Lesson 2 writes down case by case, says a request for a refund, a credit, a discount or a contract change always goes to a person, because support can't grant any of them. The draft answered the customer and left nobody on Helpline's side holding the request.

That is the lesson of G26: you can't see a policy failure by reading the reply. You have to know what the reply should have done, written down per ticket, and compare. That written-down expectation is what turns "I read some outputs" into an eval. read_five.py's one-line check is only a hook to show the problem; the eval suite starts in Lesson 2.

Notice what made G26 detectable. It wasn't a better reader. It was a policy, stated once, turned into an expected value for each ticket: this one escalates, that one doesn't. The reader of the five drafts had the knowledge base and good judgement, and still had no way to know that credit requests must reach a person. Expect many failures in your own feature to look like this one: the output is fluent and plausible, and wrong only against a rule that lives somewhere other than the output.

4. Error analysis first, criteria second

Don't start by choosing metrics. Start by reading failures, real ones, and grouping them. Then name the criteria that would catch each group. Criteria written before you have looked at failures measure what you imagined, not what goes wrong.

Reading all 40 recorded drafts against the knowledge base and the policy turns up three problems, not one:

  • G26 answers a credit request instead of escalating it, as above.
  • G16 (an admin lost the phone with the authenticator app) adds "If SMS has been disabled, another admin on your workspace will need to re-enable it." KB-105 says SMS stays available unless an admin disables it; it says nothing about who turns it back on.
  • G37 (SCIM provisioning) escalates correctly, then adds that SAML single sign-on "handles sign-in only, not automatic user creation and removal." That may well be true, but no article says it.

G26's problem is a decision: the escalate field is wrong. G16's and G37's are sentences in reply that no cited article supports. Group what you find like that, by what went wrong and where, and the run so far gives two types. The policy's promise rules and the trap tickets name two more, which this run didn't trigger but a later prompt might. Lesson 2 builds a trap case for each. This tutorial uses these four names in every lesson:

Failure typeWhere it shows upExample
Wrong policy factreply: a number or rule the knowledge base contradictsA retry count or time limit that differs from the article it cites (none in this run; the number_bait traps target it)
Missed escalationescalate: false where the policy requires trueG26 in this run
Uncited claimreply against cited_articles: a statement no cited article supportsG16 and G37 in this run
Unsafe promisereply: a commitment support can't make, such as a credit, a refund, a fix date or a feature"I've applied a service credit"

A missed escalation is the only type you can find in a single field. The other three need the reply read against the articles, which is why Lesson 3 needs a judge.

5. One criterion, one verdict

Turn each failure type into a criterion: one property of a draft that a grader decides as PASS or FAIL. "The draft escalates exactly when the policy says so" is a criterion. It fails a missed escalation, and an unneeded one too, which is also a policy mistake. "Quality: 7 out of 10" is not.

Pass/fail per criterion beats a 1–10 score for three reasons:

  • It says what changed. If v2 of your prompt nudges an average score up a little, you don't know what got better, or whether anything did. If it moves escalation from FAIL to PASS on one ticket, you do.
  • It forces a definition. To answer PASS or FAIL you must say what passing means. A score lets a grader, human or model, avoid deciding.
  • It's easier to check the grader. Lesson 3 measures how often a judge's verdict matches a known answer. That needs a yes or no to compare.

6. Three kinds of grader

Each criterion needs a grader, and there are three kinds:

  • Code. A function that reads the draft and decides. It's free, instant and never changes its mind. It can only check what is mechanical.
  • An LLM judge. A model call that returns a verdict for one criterion. It can read meaning, and it costs money, can be wrong, and must itself be measured.
  • A person. The most trusted grader and the scarcest. In this tutorial a person reviews a sample of production traffic, not every case.

Matched to the four failure types:

Failure typeCriterion (PASS when…)GraderBuilt in
Missed escalationescalate matches what the policy requires for this ticketCode: the expected value is written down per caseLesson 2
Wrong policy factevery number in the reply appears in a cited article or the ticketCodeLesson 2
Uncited claimevery article the answer needs is in cited_articles; the judge reads the sentences themselvesCode for the citations, the judge for the proseLessons 2 and 3
Unsafe promisethe reply promises nothing the knowledge base doesn't supportLLM judgeLesson 3
Anything the criteria don't name yeta person reads sampled real trafficPersonLesson 5

Two rows come with limits. The numbers check catches a wrong policy fact only when it is a number that appears in neither the cited articles nor the ticket. It can't catch a reply that repeats the customer's own wrong number, such as agreeing with G17's "24 hours". A wrong rule in words, like G16's sentence, also gets past it and is left to the judge. The citation check confirms that the right articles are listed, not that every sentence is backed by one, so G16 and G37 pass it too. Before any of these runs, a separate check confirms that the draft matches its schema at all, because without a parsable draft nothing else can be graded.

Lesson 3 adds one condition to the judge's criterion: the reply must also answer the question the ticket asked, because a reply can be safe and still useless.

The person in the last row reads a sample of real traffic and decides which new failures deserve a golden case and a criterion. That is error analysis again, run on production.

Use the cheapest grader that can decide a criterion. Escalation looks like a judgement call, but once the expected answer is written down for each ticket it is a comparison of two booleans.

The three also differ in how you trust them. You trust a code grader once you have read its failures, because a grader can be wrong too. You trust a judge only after measuring it against answers you already know, which is Lesson 3. You trust a person by default, which is exactly why their time goes to the cases nothing else can decide. Put people on every draft and the suite stops being something you can run on each change. Put them nowhere and nobody ever sees the failures your criteria didn't anticipate.

7. Offline and online

An offline eval grades a fixed set of cases before you ship a change. It answers "did this change break anything we know about?" Lessons 2 to 4 build one: 40 tickets with expected outcomes, which the series calls the golden set.

An online eval grades samples of real traffic after you ship. It answers "what's going wrong that we don't know about yet?" Lesson 5 samples production traces into a queue for a person to review.

You need both. The golden set can't contain a ticket type you've never seen. Production sampling is too slow and too noisy to decide whether one prompt edit is safe.

The two feed each other. A failure found online becomes a new golden case, with its expected outcome written down, so the next prompt change is checked against it offline. An offline suite that never takes in new cases slowly stops describing the traffic it is meant to protect.

Online review finds new failures; the golden set makes sure they stay fixed.

8. What a green eval proves

Goodhart's law: when a measure becomes a target, it stops being a good measure. Tune the drafter until all 40 golden cases pass and you have a drafter that passes those 40 cases. Whether it got better on next week's tickets is a separate question.

A green eval proves exactly this: these cases, graded by these graders, passed. It doesn't prove that the graders are right, that a small change would be visible, or that real traffic resembles the set. Lessons 2 to 5 test each of those in turn.

9. The checklist

Each lesson closes one row:

GapClosed in
No written expectation per ticket, so policy failures are invisibleLesson 2: the golden set
No mechanical checks of schema, escalation, citations and numbersLesson 2: code graders
Nothing checks whether the prose answers the question or promises too muchLesson 3: a calibrated LLM judge
"v2 looks better" is an opinionLesson 4: paired comparison with confidence intervals
Nothing stops a regression from merging, and nobody looks at real trafficLesson 5: a CI gate and a review queue

10. Common problems

  • uv run python read_five.py can't find runs/drafts-v1.jsonl. Run it from the lesson folder, not the series root.
  • uv sync fails, or Python complains about syntax. The code needs Python 3.12 or newer. Check with python3 --version, or let uv fetch one with uv python install 3.12.
  • The five drafts differ from the ones above. The sample uses a fixed seed (seed=1) in sample(). If you changed it, you'll see a different five, which is the point.

11. Exercises

1. Sample size. main() calls sample(drafts), which reads 5 drafts by default. Make it read 10, and print chance_to_see(1, 40, 10). Then find the smallest number of random drafts that sees one failure in 40 at least 90% of the time.

Verify: uv run pytest tests still reports 4 passed. Your two numbers should satisfy chance_to_see(1, 40, n) >= 0.9 for your answer n, and fail it for n - 1.

2. Error analysis. Open runs/drafts-v1.jsonl and read the drafts for G10, G22 and G31 against data/golden.json and the articles they cite, which are in data/helpline.json. For each, decide whether anything in it fails one of the four types. If something does, name the type and the field it lives in, and write a one-line PASS/FAIL criterion that would catch it.

Verify: none of the three shows a taxonomy failure. G10 and G31 stick to their articles, and G31 escalates. G22 is accurate but cites article ids inline, like "(KB-112)", which a customer can't look up. That isn't one of the four types, and it is exactly how error analysis finds a new criterion. Lesson 2's exercise turns it into a grader.

12. What comes next

Lesson 2 writes the expectations down: a golden set of 40 tickets with the escalation decision and required citations for each, the drafter itself with structured output, and four code graders that check every draft without calling a model.

Key Takeaways

  • Explain why reading five random drafts tells you little, and calculate how often a sample includes one specific failing case
  • State the drafter's contract and point to the output field where each failure shows up
  • Do error analysis before writing criteria, and file a failure under the field where the decision went wrong
  • Name the four failure types: wrong policy fact, missed escalation, uncited claim, unsafe promise
  • Rewrite a failure type as a criterion with a PASS/FAIL verdict instead of a 1–10 score
  • Choose a code grader, an LLM judge or a human for a criterion and justify the choice
  • Say what offline evals catch that online evals miss, and the reverse
  • Use Goodhart's law to say what a green suite proves and what it doesn't

Discussion

Ask questions, share what you learned, and help others.

    Loading discussion…

    Bishal SahaLet's build together

    Have a system to design, or an AI feature to get right?

    Tell me about the problem. You'll get a clear, honest view of the best way forward.

    • Reply within 24 hoursOn business days, with my honest view and a next step.
    • Accepting select engagementsArchitecture, AI features and full builds.
    • Remote, worldwideWorking with startups, SMEs and enterprises.