Writing
Evaluation Engineering: Prove the System Did the Job
Define the expected outcome before the run, check it through the entry point a user would use, turn every real failure into a regression case, and know what automated checks, human review and production monitoring each catch. Worked through a coding agent and a sorting bug.
By Ka Lun Chan · Cloud & AI · AI / Delivery / Engineering judgment
What does evaluation have to prove?
Evaluation proves that the system achieved the intended result. That means defining the expected outcome before the run, checking it through the same entry point a user or caller would use, turning every real failure into a regression case, and combining automated checks, human review and production monitoring, because each catches problems the others miss.
Part of a series on what it takes to make an AI system reliable. The loop uses a check to decide whether an agent is done. Evaluation is where that check, and every other one, gets designed.
Evaluation works at two levels, and it helps to keep them apart. One is the change in front of you: did this fix work? The other is the system that produced it: does this agent fix tickets like this reliably, and did last week’s prompt change make it better or worse? The first is testing as engineers have always done it. The second is newer, and it is what lets you change an AI system without guessing.
Define the expected outcome
The illustrative scenario: a ticket says the Quantity column on the Orders page sorts as 1, 10, 2, and a coding agent is asked to fix it. The table sorts the formatted text it displays, so “10” comes before “2”, and a quantity shown as “1,200” is text too.
The expected outcome is about what a user sees. Clicking Quantity shows 2, 10, 1,200, 5,000 and then blank rows. Clicking again reverses the numbers and keeps blanks at the end. Customer still sorts alphabetically. Nothing in that description mentions which function to change, and that is deliberate. Anthropic’s guide to agent evaluations recommends grading what the agent produced rather than the path it took to get there. An agent may find a valid fix somewhere you didn’t expect, and a check tied to one particular function would fail it.
Define success before running the agent. Claude’s prompting documentation places success criteria and a way to test them ahead of prompt work. Otherwise, the first output can bias the definition of correct.
How do you verify the fix through the normal entry point?
Drive the feature the way a user does and check what they would see. For the sorting bug, that means rendering the real Orders table with representative data, clicking the Quantity header, and reading the order of the rendered rows. Calling the sort helper directly only tests the agent’s theory of where the bug was.
const quantities = ['1,200', '10', '2', '', '5,000'];
test.each(orderings(quantities))(
'Quantity sorts numerically through the table (%#)',
async (rows) => {
render(<OrdersTable rows={rows.map(toOrder)} />);
const header = screen.getByRole('columnheader', { name: 'Quantity' });
await user.click(header);
expect(column('Quantity')).toEqual(['2', '10', '1,200', '5,000', '']);
await user.click(header);
expect(column('Quantity')).toEqual(['5,000', '1,200', '10', '2', '']);
},
);
test('Customer still sorts alphabetically', async () => { /* ... */ });The test goes through the component the user clicks, includes blanks and a thousands separator, and tries several starting orders. Number("1,200") produces NaN, so a comparator that relies on it can leave a formatted value in the wrong place.
Anthropic’s writeup on long-running harnesses describes browser automation after agents had marked features done without proper testing. Match that effort to the risk. A component test may cover sorting, while an end-to-end browser check can give stronger evidence for checkout. See How to Verify AI-Generated Code.
Turn real failures into regression cases
Every case in that test came from a failure. 1, 10, 2 is the original bug. 1,200 and the blank are where the agent’s first attempt broke. The several starting orders are there because that first attempt could pass by luck. A regression suite built from real failures is short and pointed, and each case has a reason to exist that someone can explain.
Keep them in the repository’s normal test suite, not in a folder only the agent uses. The value shows up months later. Suppose someone changes the formatter to show units, so quantities display as “1,200 pcs”. If the table had kept sorting display text, this test would catch the break on the first run. Because the fix sorts the raw value, it passes, and the test has also documented why the code is shaped the way it is.
The same habit works for the agent itself. Anthropic’s guide suggests that 20 to 50 simple tasks drawn from real failures is a good start for an agent evaluation. That is a small number. You can build it from the tickets your agent has already gotten wrong.
Evaluating the agent, not just the fix
To know whether the agent is reliable, you need a set of tasks with known good outcomes and a way to run it many times. Anthropic’s guide gives useful vocabulary: a task is one problem with success criteria, a trial is one attempt at it, a grader scores the result, and the transcript is the full record of what the agent did.
For a sorting agent, the tasks might be a dozen ordering bugs: numbers as text, dates as text, mixed case, locale-specific characters, blanks. Each has a hidden test the agent never sees. Graders can be code (run the hidden test), a model (score the report against a rubric) or a person (read a sample). Code graders are fast and objective, and they are the right default for anything with a clear right answer. Model and human graders handle judgment, such as whether the report explained the root cause clearly.
Run each task several times, because the same agent can pass on one trial and fail on the next. The guide distinguishes pass@k, the chance that at least one of k trials succeeds, from pass^k, the chance that all k succeed. If a person reviews several attempts and picks the best, pass@k is the number that matters. For an agent running unattended, every run has to work, which is what pass^k measures.
Read transcripts when a grader fails a run. A hidden test that assumes blanks sort first can reject a valid implementation if the requirement is silent. Once every case passes consistently, keep it as a regression suite and add harder cases to measure capability.
Where do automated checks, human review and production monitoring each help?
Automated checks are the fast inner layer. They run on every change and catch any failure you have written down. They can’t tell you about cases nobody thought of, or whether the behavior is what users wanted.
Human review catches guesses presented as decisions and tests that check the wrong behavior. In the two-agent review proposal, one agent implements, another reviews and a person approves. Tell the reviewer what automated checks already cover.
Production monitoring is the only layer that sees real data and real use. A negative quantity, a locale that writes 1.200 for twelve hundred, or a new column added next month will show up there first.
| Layer | Catches | Misses | In the sorting example |
|---|---|---|---|
| Automated checks | Wrong order for any case you wrote down, on every change, in seconds | Cases nobody thought of; whether the behavior is what users wanted | The five-value ordering test, run in several input orders, through the table |
| Human review | A fix in the wrong place, scope creep, a test that checks the wrong thing, a silent guess about blanks | Anything subtle in a large diff read in a hurry | A person reads the diff, the report and the new tests before approving |
| Production monitoring | Data and usage you never imagined: negative quantities, other locales, a column added next month | Problems that produce no error and no complaint | Front-end errors from the table, and support tickets that mention sorting |
Anthropic’s guide reaches a similar conclusion for agent systems: combine automated evaluations for fast iteration, production monitoring for ground truth, and periodic human review to calibrate the rest.
Sources
Checked in November against the documentation below. The test, fixtures and later formatter change are illustrative. The naive comparator’s behavior was checked in Node.
Short answers
What is the difference between pass@k and pass^k?
pass@k is the chance that at least one of k attempts succeeds, which suits tasks where a person picks the best result. pass^k is the chance that all k attempts succeed, which is closer to what you need from an agent that runs unattended, because every run has to work.
Why test through the normal entry point instead of the function that changed?
Because the function can be correct while the feature is still broken. The agent may have fixed a helper the screen no longer calls, or the bug may come from how data reaches the function. A check through the entry point a user or caller uses tests the outcome rather than the agent’s theory of the bug.
Before you trust the next green check
- Write the expected outcome in terms of what a user or caller sees.
- Check it through the entry point they use, with the cases a naive fix gets wrong.
- Add every real failure to the normal test suite, with a reason.
- For the agent itself, run real tasks several times and read the transcripts.