# Eval
<!--
ref: @protocol/eval
type: protocol
tags: [evaluation, regression testing, grader, benchmark, agent performance]
triggers: [defining an eval, before merging prompt or model changes, after model version updates, deciding whether a change improved a score, running an eval many times while improving a product, is this grader trustworthy, where do eval results and change notes live, changing eval scenarios mid-campaign, weekly checks]
trigger_prompt: When you define, run, or record an eval, decide whether a change is kept or reverted, or run a campaign of repeated runs to raise a score.
category: verify
last_reviewed: 2026-11-27
complements: [@protocol/ratchet, @protocol/agent-shipping, @protocol/dev-checklist, @protocol/loop, @protocol/devloop]
audience: [agent-author, claude-code-user, openclaw-user, terminal-only]
version: 10
updated_at: 2026-11-27T21:15:40.673Z
-->
Define, run, record, and keep or revert with an eval: benchmark vs working evals, Measure vs Claim tiers, autonomous grading, and campaign lab notebooks.
How to define, run, record, and keep or revert with an eval, so a change counts as an improvement only when the evidence says so, with no person needed in the loop. Read §The loop every time; fetch other sections by heading (`?section=`) when you reach that step.
## The loop
1. **Define** the eval: target, bar, scenarios, grader, kind, tier (§Define an eval).
2. **Calibrate the grader** on its frozen known-good and known-bad answers. It scores nothing until it passes (§Autonomous grading).
3. **Baseline**: run the current build at least twice. The spread is the noise floor.
4. **Predict, then change**: write the expected score and why in the notebook, then make one change (§Campaigns).
5. **Run and record** one row per run (§Run, §Record).
6. **Keep or revert** by the rule in §Keep or revert, and log the verdict with its reason. Rejected rows stay.
7. **Land, then check later** against the real world on a set date.
## The parts of an eval
| Part | What it is | Example (support agent) |
|---|---|---|
| **Target** | The behavior wanted, in plain words, plus a pass bar set before any run | Resolves the ticket without inventing policy; bar 80/100 |
| **Environment** | All the system under test can touch: model, prompts, tools, data, network. Named by a config id and hashed | Prompt v12, refund tool stubbed |
| **Scenario** | A starting state plus a trigger. Names an environment, never contains one. Versioned | Refund asked outside the window |
| **Grader** | Reads the run record (end state, files, rows, exit codes, transcript if an agent ran) and scores each criterion. Deterministic, model rubric, or human. Versioned | Policy cited 0-2; check that no refund call fired |
| **Run** | One execution: scenario × environment × grader version × time. Append-only | Run 41: prompt v13, 74 |
| **Experiment** | Baseline against variants, with repeats | v12 vs v13, 3 repeats each |
Use a deterministic grader wherever a program can decide the criterion; a model rubric only for the rest.
## Benchmark or working eval
- **Benchmark** (hard): scenarios and grader frozen, never edited during a campaign. It changes only as a new version, between campaigns.
- **Working eval**: scenarios may co-evolve with the work (one added to exercise a new feature, one rewritten because it tested the wrong thing). Each change bumps the scenario version with a reason, and the current build is re-scored on the new version.
Scores compare only within one version; a jump across a version bump is not progress.
**Guard:** a change cannot be kept on a working eval alone. It must also hold or beat the frozen benchmark for the same target. With no benchmark, a change can be measured but not kept.
## Measure or Claim
**Measure** watches a number. **Claim** is required before anything is called kept, better, or done. A Measure result is labelled "measured", never "kept".
| Required | Measure | Claim |
|---|---|---|
| Target and bar, written before any run | yes | yes |
| Rubric: criteria and scale | yes | yes |
| At least 3 cases, one a near-miss (looks like it should fire, should not) | yes | yes |
| How to run: command, environment id, cost per run | yes | yes |
| Prediction (expected score and why), written before the run | | yes |
| Grader audit passed on this grader version | | yes |
| Held-out cases, frozen, never used while tuning | | yes |
| At least 3 runs per arm, same window | | yes |
| Confidence interval on the difference that clears the noise floor | | yes |
## Where things live
| Thing | Lives in |
|---|---|
| Behavior eval (no code to run) | A protocol entry tagged `eval`: definition and run records |
| Code-driven suite | `EVAL.md` in the product repo, same headings, pinned to a commit, beside its scenario code and fixtures; plus one thin protocol entry tagged `eval` holding the bar and run records |
| Run records | Always on the eval's protocol entry |
| Eval entries | Under an `eval/` path in their repo (`@repo/eval/<name>`), not at the repo root: they are peers, and `/ls/@repo/eval` shows the set |
| The work raising the score | The story or epic doing it: its lab notebook (§Campaigns) |
Every run row carries its commit, so any step in the history can be re-run.
## Define an eval
Headings, in the entry or `EVAL.md`: **Target** · **Bar** · **Kind and tier** · **Environment** (config id, what is stubbed, how it is sandboxed so nothing real is sent) · **Scenarios** (id, version, starting state, trigger, what is observable; held-out ones marked) · **Grader** (kind, version, criteria, calibration set, second grader) · **How to run** (one command from a clean checkout, cost) · **Regression set** (other targets that must stay above their bars).
Source scenarios from real failures: each failure seen in real use becomes a scenario before it is fixed (for a benchmark, in its next version). Add near-misses, one malformed input, and one empty input.
## Run
- **Prediction first.** A prediction written after the result is not one.
- **Held-out cases stay frozen**: never read while tuning, never edited.
- **Infrastructure failures are re-run, not counted.** A timeout, rate limit, crashed sandbox, or missing credential is not a score.
- **Check the change took effect**: hash, version string, or a probe in the record shows the run saw it. If not, the row is `not-applied` and not a result.
- Pair control and treatment in the same window; day-to-day drift is noise.
- **The run cannot see its own eval.** A run that reads the eval entry (rubric, cases, bar) is invalid and re-run. Enforce it, do not trust it: run under a learning token that omits the eval entry, so the ref 404s and search never surfaces it. Backstop: scan the tool-call record for any fetch of the entry. Put an explicit bearer in the token config; a client that falls back to anonymous produces denials that look like isolation and prove nothing.
## Record
One row per run on the eval's entry:
`time · commit · environment id + hash · scenario version · grader version · score (total and per criterion) · cost · status · what changed (one line)`
`status`: `scored`, `infra-rerun`, `not-applied`, or `flagged` (with the reason). **Rejected results are never deleted**: a reverted change's rows are the evidence for the revert and the noise floor for the next try. Keep definition and rows in separate sections, so the definition can be edited without touching history.
## Keep or revert
Keep only if all hold: the result is Claim tier; the confidence interval clears the noise floor; no regression-set target drops below its bar; on a working eval, the benchmark holds or improves. Otherwise revert. Either way, log the verdict and reason and keep the rows.
A kept change **lands** (merged, published, or made the default) and the verdict says where. Then it gets a **dated real-world check** with a pass mark written in advance. If the real world disagrees with the eval, the real world wins: revert or reopen the change, and give the eval a new version (new scenario or fixed grader). Pattern: `@protocol/ratchet`.
## Autonomous grading
No step needs human labels.
- **Calibration set.** Each grader has frozen known-good and known-bad answers. A grader version must score every known-good above the bar and every known-bad below it, and agree with itself on a repeat, before it scores anything. A failing grader is fixed as a new version, never overridden.
- **Second grader.** A Claim-tier eval with a model grader also grades with a second grader from a different model family. Disagreement beyond the rubric's tolerance marks the run row `flagged` on the eval entry (the results feed is simply the flagged rows); it pages no one, and a flagged row cannot support "kept".
- **Human review is optional sampling.** Anyone may read graders and results; nothing waits on them.
## Campaigns: improving against an eval
A campaign is a story or epic aimed at raising a score: building code, running scenarios many times, tuning, proposing better scenarios. That story or epic is the **lab notebook**:
- **Body: the current strategy** (what is being tried and why, what is ruled out). Edit it in place; do not append.
- **Log: every iteration**, one entry each: change → run row ids → score → keep or revert → why. This is the evolution path; never rewrite or prune it. A working-eval scenario bump is logged here too, with its reason.
- It closes on a Claim-tier verdict that includes the benchmark, not on the working eval's trend.
---
## Appendix A: first harness, pitfalls, when to run
**First harness.** A shell script with `curl` and `jq` is enough; move to a framework when a script stops scaling.
```python
for case in load("cases.jsonl"): # {id, version, input, expected, held_out}
record = run_system(case["input"]) # end state, outputs, transcript if any
append_row(case, grade(record, case["expected"]))
```
| Output | Deterministic check |
|---|---|
| JSON | Field match or schema |
| Classification | Label match |
| Extraction | Share of expected entities present |
| Tool calls | Tool names and required keys; done within N calls |
| Free text | Required substrings, then a rubric for the rest |
**Pitfalls.** Assertions that always pass (`not None`, `len > 10`): write the check that would have caught the last real failure. Happy-path cases only. Editing held-out cases or a benchmark mid-campaign. Comparing scores across scenario versions. A big suite nobody runs: gate on a fast subset, run the rest on a schedule. A public benchmark as go/no-go: direction only.
**When to run.** Before merging a prompt, tool, or model change; after a model version bump; on a schedule for drift you did not cause; at each staged rollout step (`@protocol/agent-shipping`).
## Appendix B: history
- **v1–v6 (to 2026-04):** a minimal regression harness: golden dataset from production failures, CI gate, anti-patterns, tooling tiers. No grader audit, record format, keep-or-revert rule, or model for scenarios that change with the product.
- **v7 (2026-11-27):** rewritten as the full loop: six parts; benchmark vs working eval with the benchmark guard; Measure and Claim tiers; where definitions, records and notebooks live; autonomous grading (calibration set, second grader from another model family); campaigns as lab notebooks. The golden-dataset practice is kept as the scenario-sourcing rule; harness, pitfalls and run moments moved to Appendix A. Dropped: the multi-step-agent table (folded into the harness table and the run-record grader), the tooling-tier ladder, and the 20–50 / 200-case sizing guidance.
---
*Related: `@content/web/xinyadu/2026-11-29-claude-code-task-framing-study` · `@content/web/huggingface/2026-11-27-os-omni-computer-use-benchmark` · `@content/youtube/sequoia/how-companies-are-building-their-own-intelligence-sonya-huang-sequoia-capital` · `@content/youtube/langchain/managed-deep-agents-conceptual-video` · `@content/youtube/cole-medin/im-building-an-ai-dark-factory-that-ships-its-own-code-public-experiment`*
---
*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*
*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*