# Chapter 24. Evaluating AI Workers: Golden Sets, Judges and Failure Modes (/building-ai-workers/evaluating-ai-workers/overview)

---
type: Document
title: 'Chapter 24. Evaluating AI Workers: Golden Sets, Judges and Failure Modes'
description: 'Make the AP expert''s judgment travel to the answers she will never read: a golden set she labels, checks by code on every pull request, an LLM judge calibrated against her marks, metrics you can defend, and failures named and fixed by their cause. Built on Claude first, then ported to OpenAI and to open source.'
status: stable
order: 324
ksor:
  owner: team:panaversity
  audience:
    - public
  approval:
    by: process:panaversity
    at: 2026-11-30T00:02:23Z
chapter: '24'
part: III
expert_status: co-build
objectives:
  - id: CCDV-F.D4.S1
    label: primary
  - id: CCDV-F.D4.S2
    label: primary
word_budget: 4000
prerequisites:
  - '01'
  - '02'
  - '03'
  - '04'
  - '05'
  - '06'
  - '07'
  - '08'
  - '09'
  - '10'
  - '11'
  - '12'
  - '13'
  - '14'
  - '15'
  - '16'
  - '17'
  - '18'
  - '19'
  - '21'
  - '22'
  - '23'
build_step: 'A regression suite for the AP worker: Ana''s 40 labeled cases, checks by code in CI, an LLM judge calibrated against her marks, six named failure traces, and a port of the judge to OpenAI and to open source'
artifact: brightline-ap with data/golden/cases.yaml, data/golden/labels.csv, data/golden/marks.csv, npm run eval, .github/workflows/eval.yml, tag ch24
lab_data: https://github.com/panaversity/agentfactory-v2-resources/releases/latest/download/brightline-lab-ch24.zip
delta_entries: []
concepts:
  - '24.1'
  - '24.2'
  - '24.3'
  - '24.4'
  - '24.5'
  - '24.6'
  - '24.7'
  - '24.8'
  - '24.9'
  - '24.10'
last_verified: '2026-11-29'
sources:
  - id: prep-course-module-4
    title: 'Claude Certified Developer, Foundations prep path, Module 4: Production Engineering, Evals, and Security (Anthropic Partner Academy, sign-in needed, read 2026-11-29)'
    resource: https://anthropic-partners.skilljar.com/path/claude-certified-developer-foundations/production-engineering-evals-security/486745/scorm/1twknqoor0w46
generated:
  at: 2026-11-30T00:02:23Z
  by: esl-rewrite/1.2.0+ksor.1
trust_tier: unverified
build_id: sha256:cc6fd9ac5f72207d4365ecbda63d87d1b64f99e05519b358a45b9f5d9bfd6f8f
dirty: true
ksor_version: 0.0.60
---

## Start here if you skipped Chapter 23

*If you read [Chapter 23](../hosted-agents/overview.md), skip this. If you came from an earlier chapter, these are the words this chapter builds on. Each is explained again, briefly, where it is used.*

| Word | What it means | Where this chapter uses it |
| --- | --- | --- |
| **The AP worker** | Brightline's AI Worker for accounts payable (AP), the team that checks and pays a company's bills. It answers questions about invoices and policies, and cites a policy line for each answer | Everywhere |
| **The portal** | Brightline's own web site, where a person signs in and asks the worker a question. Its code also starts the worker's runs | 24.3 |
| **Session** | One run of the hosted worker, with its events recorded by the platform | 24.7, 24.8 |
| **The morning triage** | A scheduled run that starts at 7:10 every weekday, with a budget of $0.50. It gives every open invoice one decision and a policy line, with nobody at a desk | The point, 24.3 |
| **Check by code** | Plain code that compares the worker's report with something the model did not write, such as the tool results the platform recorded ([23.16](../hosted-agents/loops-check-feedback-and-stop.md)). It is the **gate**: the check that decides whether work may go on | 24.3 |
| **Grader** | A separate checker with its own context window. It judges, and it can be wrong ([23.17](../hosted-agents/patterns-and-when-to-host-it-yourself.md)) | 24.4 |
| **Stop reason** | Why one model response stopped: finished, wants a tool, declined, and a few more ([21.3](../agent-loop-by-hand/one-turn-request-response-and-stop-reason.md)) | 24.7, 24.8 |
| **Status** | The number an API response carries. 200 means the API accepted the request. 400 means it rejected the request ([21.9](../agent-loop-by-hand/when-the-loop-goes-wrong.md)) | 24.7, 24.8 |
| **Trace** | The record of one run, step by step: each request, each tool call and each result ([21.10](../agent-loop-by-hand/reading-a-trace.md)) | 24.7, 24.8 |
| **Schema** | A written description of what valid data looks like: which fields, which types, which values ([14.5](../structuring-programs/schema-rules.md)) | 24.1, 24.3 |
| **Answer check** | Four questions written with the AP expert in Chapter 19, one of them Brightline's, each with the decision she expects, the line it must cite and the claim it must not make. She read each answer by hand ([19.16](../business-data-and-retrieval/measuring-retrieval.md)) | 24.2 |
| **Staging workspace** | A separate part of the account for tests, with its own keys and its own spending limit ([23.4](../hosted-agents/resources-as-code.md), and its spending limit in [23.13](../hosted-agents/keys-that-expire-and-no-keys-at-all.md)) | 24.4, Lab 24 |

## The point

Monday, April 12, 2027. At 7:10 the AP worker ran the morning triage, as it does every weekday. It gave every open invoice a decision and a policy line, inside its budget of $0.50. Before the session started, the portal's code had read each new invoice and written down its fields. Nobody was at a desk.

At 8:40 Ana Morales arrives. Ana is Brightline's AP analyst, and the worker's rules are hers. She has twenty minutes for the worker today. The triage is already done. On Friday the builder also opened a pull request that changes the worker's prompt, and a test run put 40 cases to the changed worker. That is 40 more answers. Tomorrow at 7:10 there will be more, and the day after that.

The book's operating rule says: humans define intent, AI Workers execute, humans verify outcomes. In Chapter 19 the check was reading. An AP expert read four answers, one of them Brightline's, and marked each one pass or fail ([19.16](../business-data-and-retrieval/measuring-retrieval.md)). That worked for four answers at a desk. It does not work for a worker that runs before she arrives.

<!-- EDITOR: 19.16's answer check has four rows, three of them Cedar Ridge's and one Brightline's, and it says "the AP expert", not Ana. So the page now says an AP expert read four answers, one of them Brightline's, here, in the skip table and in 24.2. The other option: keep the spec's reading, in which Ana's own check held all four. -->

So this chapter asks one question. **Ana cannot read every answer the worker gives. Who speaks for her on the answers she will not read?**

## Why it matters

Anthropic's exam prep course tells this story.[^prep-course-module-4] A team built a feature that read order documents and pulled out their fields. The team checked a dozen results by hand, and every result passed every validation rule. Then a document said "ordered on March 3, received April 12". The feature took April 12 as the order date. The value was a real date in the right field, so every rule passed it. The rules checked the shape of the value. Nobody had written down the right value for a document with two dates, so nothing could say this one was wrong.

Brightline's worker can fail in the same hidden way. An answer can cite the right policy line, name the right approver, and still put two steps in the wrong order. A total can be a valid number of cents and still be the wrong number. No error appears, and every response ends in a normal way. The only thing that can tell a right answer from a wrong one is the judgment of the person who knows the work.

## How this chapter works

**Ana's judgment reaches the worker's answers in three carriers.** A carrier is something that holds her judgment and takes it where she is not.

1. **She writes it down once.** For each of 40 cases, Ana gives the answer she expects. These 40 cases are the **golden set**, and her expected answers are her **labels** (24.1, 24.2).
2. **Code checks what code can,** **on every pull request.** Each extracted field is compared with her value. Each answer must cite her line and contain her words. **A check by code** stays the gate (24.3).
3. **A judge** **reads what only reading can check,** such as the order of two steps. The judge is a separate model with a **rubric**, a written list of what a good answer has, made from Ana's reasons. It marks each answer correct, incorrect or unknown (24.4). Its marks count only as far as it agreed with Ana on 10 **held-out** answers, which are answers it never saw while its rubric was written (24.5).

<!-- FIGURE 24.1: Ana's judgment in three carriers. On the left, a box labeled "Ana Morales, AP analyst". An arrow points right from Ana to a gold box labeled "The golden set: 40 cases, her labels", and the arrow is labeled "she writes it down once". From the golden set, two lanes run right to a box on the far right labeled "The worker's answers". The upper lane is a box labeled "checks by code, every pull request", with an arrow from the golden set into it and an arrow from it to the worker's answers. The lower lane is a box labeled "the judge, where only reading can check", with an arrow from the golden set into it and an arrow from it to the worker's answers. Under the lower lane, a small note: "counts only as far as it agreed with Ana on 10 held-out answers". Three red-orange arrows run back from right to left, from the lanes and the worker's answers to Ana, labeled "every incorrect", "every unknown" and "every live failure". A caption line below: "She reads what comes back, not everything." -->

*Figure 24.1. Ana writes the golden set once. Code and a judge carry her judgment to the worker's answers. Every "incorrect", every "unknown" and every live failure comes back to her.*

**What Ana still reads.** She reads every answer the judge marks incorrect or unknown, and every failure found in live work. On this Monday that is one answer, and the chapter follows it from Friday's pull request to her mark. When she agrees an answer failed, the builder reads its trace and names the failure (24.7 to 24.9).

**What this does not reach.** The worker that writes the 7:10 answers is one that passed the suite. The suite is the 40 cases run together as one test. Each morning's report is still checked by code against its tool results. The invoices that the portal's code extracts each morning get only a check of shape, until Chapter 25 adds a check of value. But a live answer unlike any of the 40 cases reaches Ana only when she or a check finds it wrong. Reading a sample of live answers is Chapter 35's subject.

<!-- EDITOR: the page points to Chapter 35 (here, in 24.3, in 24.5 and on the last flashcard), to Chapter 29 (24.6) and to Chapter 26 (24.9), and the book has none of the three yet. They are kept because the spec fixes "Chapter 35" as a required string and names Chapter 29 for the release step. The other option: cut each pointer until its chapter exists (docs/authoring.md, section 5). -->

Concepts 24.1 to 24.9 teach the method. Where one needs a product fact, it says so in a line marked **In Claude**. Concept 24.10 compares Claude, OpenAI and open-source tools, and the lab names the tools it uses.

## What you will build

**Who's who.** You are the builder. You build and run the AP worker for Brightline, with coding agents. Ana Morales is Brightline's AP analyst. She labels all 40 cases, and she defines what a good answer is. This chapter needs her at every step, so plan the work with your own expert the same way.

**Where you are.** At the end of Chapter 23 the worker runs as a hosted agent inside Brightline's portal. It answers questions, and it triages open invoices at 7:10 every weekday. Nothing yet says whether a change to the prompt made the answers better or worse.

**What you build.** As before, coding agents write every file and run every command. You specify, check and approve.

1. **An extraction step.** Extraction means reading a document and writing its fields as data. For each new invoice, the portal's code calls the model once, before the 7:10 session starts, and asks for the invoice's fields as JSON. Code checks the result with Chapter 14's schema. A result that fails goes to `needs_review`, with no retry.
2. **The golden set:** 40 cases in `data/golden/cases.yaml`, which are 25 AP questions and 15 invoice extractions, with Ana's labels in `data/golden/labels.csv`.
3. **The suite.** `npm run eval` runs the 40 cases, and `.github/workflows/eval.yml` runs them on every pull request, with a pass threshold, the lowest result that still passes.
4. **A judge,** with a rubric written from Ana's reasons, measured against **her marks**, her pass or fail on recorded answers, on answers it never saw.
5. **A report** that shows, for every result, who marked it: code, the judge or Ana.
6. **Six recorded traces,** one for each kind of failure, which you name and sort. One goes back into the golden set as a new **case**, with Ana's **label**. The set then has 41 cases, and the threshold moves from 39 of 40 to 40 of 41.

The lab takes three sittings and ends tagged `ch24`. The chapter's story shows the finished suite at work, and in the lab you build it. It ends with one extraction case still failing, on purpose. Chapter 25 starts from that case.

<!-- EDITOR: the story and the lab share Monday, April 12, 2027, the date the spec proposes for the lab. The page now says the story shows the finished suite, and the lab builds it. The other option: move the lab's date before Friday, April 9. -->

## In this chapter

| Concept | The question it answers |
| --- | --- |
| 24.1 From a **quality goal** to a **measure** | How does something Ana says become a check that anyone can run? |
| 24.2 Golden sets, written with the expert | Where is her judgment written down, and which cases belong in it? |
| 24.3 Behavioral checks and regression tests in CI | What can code check on every pull request, and why does code stay the gate? |
| 24.4 **LLM-as-judge**: a rubric and a separate model | Who reads what only reading can check? |
| 24.5 Calibrating the judge against human labels | Why should a model's mark count at all? |
| 24.6 Metrics you can defend | What does a number say, and what can 40 cases not show? |
| 24.7 Naming the failure | Which of six failures is this one? |
| 24.8 **Integration layer** or **model output** | Did the fault begin in the code around the model, or in what the model wrote? |
| 24.9 Recovering by **cause**, not **symptom** | Which fix removes the cause, and how does the failure stay fixed? |
| 24.10 How today's tools realize it | Which carrier is each of today's tools? |
| Lab 24 | Ana's labels first. Then the extraction step, the suite and the judge, a broken prompt the suite catches, and six traces to name |

[^prep-course-module-4]: Claude Certified Developer, Foundations prep path, Module 4: Production Engineering, Evals, and Security, Anthropic Partner Academy.
