Docs Evals
View as Markdown

Run your first eval

Write the cases, point coding.sh at the command that answers one, read the pass rate per case, then fix the failures and compare the two runs.

An eval has three parts: cases (an input and, when you have one, the expected answer), the task (the command that answers one case) and graders (what decides pass or fail).

Step by step

This eval tests the triage agent from the Quickstart, which labels coding.sh's GitHub issues. Any program that reads an input and prints an answer works the same way, in any language.

1. Write the cases

One JSON object per line: the issue title as input, and the labels you expect as expected.

cases.jsonl
{"input": "Viewer search misses tool output", "expected": "bug, viewer"}
{"input": "Add a --json flag to coding.sh usage", "expected": "enhancement, cli"}
{"input": "Codex sessions show no cost", "expected": "bug, cost"}

2. Let the agent read a case

eval run sends each case's input to your command as JSON on stdin and grades what it prints. The quickstart agent takes the issue as an argument, so add the three lines that read stdin:

triage.mjs
import OpenAI from "openai";
import { observe } from "@codingdotsh/sdk";

const openai = observe(new OpenAI()); // records each call: prompt, answer, tokens, cost

// eval run sends each case's input as JSON on stdin; from a terminal, pass the issue as an argument
let stdin = "";
if (!process.argv[2]) for await (const chunk of process.stdin) stdin += chunk;
const issue = process.argv[2] ?? JSON.parse(stdin);

const res = await openai.chat.completions.create({ model: "gpt-5-mini", messages: [
  { role: "system", content: "Pick labels for this GitHub issue from the repo's label list. Answer with the labels only." },
  { role: "user", content: issue } ] });
console.log(res.choices[0].message.content);

3. Create the suite

coding.sh eval init triage --cases cases.jsonl --command 'node triage.mjs'
~/triage
$ coding.sh eval init triage --cases cases.jsonl --command 'node triage.mjs'
✓ Wrote regression suite triage (cases) to evals/triage
  evals/triage/suite.json
! 3 cases: grow toward 20 to 50 from real failures; a small suite only shows large changes

  Regression suite: should pass nearly every time. `eval run` exits 1 when a task fails most of its trials.
  Trials: 3 per case; the report gives pass@3 (passed at least once) and pass^3 (passed every time).

  Run it:
    coding.sh eval run triage

  To run it on every pull request, save this as .github/workflows/evals-triage.yml:
name: evals (triage)
on: pull_request
…

This writes evals/triage/suite.json in your repo, so the suite is reviewed like code. The expected answers are short, so it grades with exact, ignoring case and extra spaces. The output ends with a GitHub Actions workflow that runs the suite on every pull request; see Run it on every change.

4. Run it

coding.sh eval run triage
~/triage
$ coding.sh eval run triage

triage  regression suite · 3 cases · 3 trials each
pass@1  66.7% [35.4%, 87.9%]  (6/9 trials, 95% Wilson)
pass@3  66.7%  a case counts when any of 3 trials passes
pass^3  66.7%  a case counts only when all 3 trials pass

case                                  passed         first failure
------------------------------------  ------  -----  --------------------------------------
Codex sessions show no cost              0/3  never  exact: expected "bug, cost", got "bug"
Add a --json flag to coding.sh usage     3/3  ok
Viewer search misses tool output         3/3  ok

never passed: Codex sessions show no cost. Read its transcript or output first: a case no trial passes is most often a broken case or grader, not a weak agent.
3 cases: a suite this small only shows large changes; grow it toward 20 to 50 cases from real failures
regression suite: Codex sessions show no cost fails most trials
experiment exp_01M75HB4GTTGK0S04PB0VXSKY2

Read the report

LineWhat it tells you
pass@1The share of all trials that passed, with a 95% interval. Each case runs 3 times by default (-k).
pass@3The share of cases that passed at least once in 3 trials.
pass^3The share of cases that passed every trial. Use it when the agent must work every time.
Case rowsEach case by its input, its passed trials, and the first failure's reason. flaky marks a case that passed some trials.
never passedA case no trial passed. Check the case and the grader before you blame the agent.
experimentThe stored run. coding.sh exp show <id> lists every trial.

Here the agent answers "bug" for "Codex sessions show no cost", and the case expects "bug, cost". This is a regression suite, so eval run exits 1 while any case fails most of its trials.

5. Fix it and compare

The system prompt asks for labels "from the repo's label list" but never gives the list, so the model doesn't know cost is a label. Name the labels in the system message of triage.mjs:

triage.mjs
{ role: "system", content: "Pick labels for this GitHub issue from these labels: bug, enhancement, cli, viewer, cost, docs. Answer with the labels only." },

Run the suite again:

~/triage
$ coding.sh eval run triage

triage  regression suite · 3 cases · 3 trials each
pass@1  100.0% [70.1%, 100.0%]  (9/9 trials, 95% Wilson)
…
Add a --json flag to coding.sh usage     3/3  ok
Codex sessions show no cost              3/3  ok
Viewer search misses tool output         3/3  ok
…
experiment exp_01M75HBMX4HBKBXWPPB696R4B5

Each run is stored as an experiment. Compare the two, case by case:

coding.sh exp compare exp_01M75HB4GTTGK0S04PB0VXSKY2 exp_01M75HBMX4HBKBXWPPB696R4B5
~/triage
$ coding.sh exp compare exp_01M75HB4GTTGK0S04PB0VXSKY2 exp_01M75HBMX4HBKBXWPPB696R4B5
A triage exp_01M75HB4GTTGK0S04PB0VXSKY2  pass 66.7%
B triage exp_01M75HBMX4HBKBXWPPB696R4B5  pass 100.0%
…
B − A   +33.3pp [0.0pp, +100.0pp] (3 paired cases, 95% paired bootstrap)
mcnemar p=1.000  0 regressed, 1 improved  sign-flip p=1.000 over 3 cases
…
verdict inconclusive (CI includes 0)
…
! only 3 paired cases (< 200): small suites detect only large effects and their intervals can under-cover; add cases or trials before trusting a null result
…
improvements 1
case                 A     B       Δ
------------------  --  ----  ------
c_4e1e9ed337bf6b6d  0%  100%  +100pp

The fix passes the case that failed and breaks none. With 3 cases, the verdict stays inconclusive: a suite this small shows that a case changed, not that the change will hold. Add cases from real failures before you rely on the verdict. Reading the comparison is covered in Experiments.

Grade without an exact answer

When an answer can be right in more than one way, leave out expected and describe a good answer with --describe. eval init then grades with an LLM judge that uses your description as its rubric.

issues.jsonl
{"input": "Viewer search misses tool output"}
{"input": "Add a --json flag to coding.sh usage"}
{"input": "Codex sessions show no cost"}
coding.sh eval init triage-judged --cases issues.jsonl --command 'node triage.mjs' \
  --describe 'Pass if the labels name the kind of issue (bug or enhancement) and the part of coding.sh it is about (cli, viewer, cost or docs).'
coding.sh eval run triage-judged -k 1
~/triage
$ coding.sh eval run triage-judged -k 1

triage-judged  regression suite · 3 cases · 1 trial each
pass@1  100.0% [43.9%, 100.0%]  (3/3 trials, 95% Wilson)

case                                  passed      first failure
------------------------------------  ------  --  -------------
Add a --json flag to coding.sh usage     1/1  ok
Codex sessions show no cost              1/1  ok
Viewer search misses tool output         1/1  ok
…

The grader it writes to evals/triage-judged/suite.json:

suite.json
"graders": [
  {
    "kind": "llm",
    "name": "does-the-job",
    "rubric": "Pass when the output does this, correctly and completely: Pass if the labels name the kind of issue (bug or enhancement) and the part of coding.sh it is about (cli, viewer, cost or docs)."
  }
]

The judge calls Anthropic with ANTHROPIC_API_KEY by default. With only an OpenAI key, add provider and model to the grader. The run above used this one:

suite.json
{
  "kind": "llm",
  "name": "does-the-job",
  "provider": "openai",
  "model": "gpt-5-mini",
  "rubric": "Pass when the output does this, …"
}

LLM judges covers the other providers, judging on a Claude or ChatGPT subscription, and checking the judge against your own labels before you trust it.

Run it on every change

  • In CI. Save the workflow eval init printed as .github/workflows/evals-triage.yml and add OPENAI_API_KEY to its env. It comments on the pull request and fails when a case breaks. See Catch a regression in CI.
  • Before and after a change. Each eval run is stored as an experiment, so coding.sh exp compare <before> <after> pairs the two runs case by case. See Experiments.
  • coding.sh eval run triage --summary "$GITHUB_STEP_SUMMARY" also appends the report as Markdown to a file, here the GitHub Actions job summary.

Turn failed runs into cases

The runs your agent already got wrong make the best cases. coding.sh dataset add <name> --session <id> keeps any recorded run as a case, and coding.sh eval init --sessions turns a coding agent's flagged sessions into repo tasks. See Turn failed runs into evals.

Suites or datasets

A suite (eval init, eval run) is a folder in your repo that runs the same way on every machine and in CI. A dataset (coding.sh dataset add, exp run) keeps versioned cases in the coding.sh store, with train, dev and test splits. Use a dataset to compare configurations, sweep models or collect cases from sessions; see Experiments.

Both store experiments, so exp compare works on either.

When cases test a change, give each one a kind. exp compare then names the bad cases the change fixed and the guards and controls it broke.

KindBefore the changeAfter the change
badFails: it reproduces the failure the change is for.Passes.
guardPasses: behavior that already works.Passes.
controlPasses: the fix must not kick in here.Passes. A failure means the change overcorrected.

Graders

A grader is a JSON object with a kind, in a suite's graders or after exp run --grader. A run passes when every grader passes it. Graders that compare with an answer use the case's expected unless the spec gives value.

KindPasses whenSpec
exactThe output equals the answer. JSON compares by structure, text after normalize.{"kind":"exact","normalize":{"caseInsensitive":true}}
containsThe output contains every string ("mode":"any": one of them). negate inverts it.{"kind":"contains","value":["bug","viewer"]}
regexThe pattern matches the output.{"kind":"regex","pattern":"^(bug|enhancement)\\b"}
json-schemaThe output validates against the schema.{"kind":"json-schema","schema":{"type":"object","required":["labels"]}}
json-pathThe value at path equals equals, or the same path in expected.{"kind":"json-path","path":"$.labels[0]","equals":"bug"}
numericThe first number (or the one at path) is within abs or rel of the answer.{"kind":"numeric","path":"$.total","abs":0.01}
similarityEdit-distance similarity to the answer is at least threshold (default 0.8).{"kind":"similarity","threshold":0.8}
commandYour script, in any language, reads the case and output as JSON on stdin and exits 0. If it prints false, a low score or {"pass":false}, the run fails.{"kind":"command","command":"python3","args":["grade.py"]}
moduleA JavaScript module's exported function returns a passing grade.{"kind":"module","module":"./grade.mjs"}
llmA model judge passes the output on your rubric. See LLM judges.{"kind":"llm","name":"labels-fit","rubric":"…"}
llm-checklistNo critical question is answered no, and at least half the yes/no questions (passThreshold) are answered yes.{"kind":"llm-checklist","name":"triage","items":[{"id":"kind","question":"…","critical":true}]}
llm-panelOne judge per provider scores 1 to 10, and the median reaches target (default 7).{"kind":"llm-panel","name":"labels","rubric":"…","members":[{"provider":"anthropic"},{"provider":"openai","model":"gpt-5-mini"}]}
callsThe run's trace has the tool calls in must, none in mustNot, and at most max calls.{"kind":"calls","must":[{"tool":"Bash"}]}
progressThe trace went off track (looping, churn, stalling) at most maxDerails times (default 0).{"kind":"progress"}
executabilityThe trace has at most maxInvalid tool calls the agent's harness refused (default 0).{"kind":"executability"}
agent-slopThe lines the agent's diff adds have at most maxErrors findings, such as as any or an empty catch (default 0).{"kind":"agent-slop"}

Try a grader on one output before you add it: coding.sh judge grade --grader '<spec>' --output answer.txt.

How pass@k and pass^k are computed

For a case with n trials of which c passed, pass@k is 1 − C(n−c, k) / C(n, k), the chance that at least one of k trials drawn from them passes. pass^k is C(c, k) / C(n, k), the chance that all k pass.

The report averages both over cases; k is the fewest trials any case has. pass@1 is c / n over every trial, with a Wilson interval.

The formulas, the paired comparison and judge calibration are on How evals are computed.

Next steps