Replay
The replay runs past pull requests through the review engine and measures its findings against the comments human reviewers left on those pull requests. Use it to compare a model, a prompt contract or a setting against a baseline before you change your deployment.
It reads from GitHub and calls the model, so it makes paid model calls. It posts nothing.
Run a replay
Section titled “Run a replay”export GITHUB_TOKEN=... # a read-only tokenexport OPENROUTER_API_KEY=... # or the variable your configuration names
npm run eval:replay -- --cases ../cases.jsonl --out ../runs/first --label first --config config.local.ymlnpm run eval:compare -- ../runs/baseline/summary.json ../runs/first/summary.jsonThe case file and the output folder must be outside the project folder, so that private data cannot be committed by accident.
The command prints cases <n>, failed <n>, not started <n>, total_cost <x>, and stopped: max_cost when the cost limit stopped it. It writes into the output folder:
| File | What it holds |
|---|---|
results.jsonl |
One row per case: status, cost, tokens, calls, duration, models, findings, highest score. |
summary.json |
The metrics below, and the case file’s sha256. |
summary.md |
The same metrics as a table. |
unmatched-sample.jsonl |
Up to 40 findings that matched no label, to read by hand. |
An output folder that is not empty is refused unless you pass --force.
Options
Section titled “Options”| Option | Default | What it does |
|---|---|---|
--cases |
required | The case file. |
--out |
required | The output folder. |
--label |
required | The run’s name in its summary and in comparisons. |
--config |
required | The configuration to review with, usually config.local.yml. |
--max-cases |
60 |
The most cases to run. |
--max-cost |
10 |
No new case starts once the run’s cost reaches this. |
--concurrency |
2 |
Cases run at once: 1, 2 or 3. |
--force |
off | Reuse an output folder that is not empty. |
--plain |
off | Run the plain control instead of the engine (see Benchmark). |
--lessons |
none | Review each case with the lessons live at its date (see below). |
The cost is the one the provider reports, as OpenRouter does, or else it is computed from model.prices in your configuration. With neither, the cost counts as zero and --max-cost stops nothing.
The case file
Section titled “The case file”A case file is JSON Lines. Each line names one pull request at a fixed head and base (repo, pr_number, head_sha, compare_base, with its title, description, branches and author), and the review comments people left on it as labels. Each label has a path, a line or null for the whole file, a side, a severity, and a kind:
valid: a comment the team judged valid; the engine should raise it.invalid: a comment the team judged wrong; the engine should not repeat it.first,late,escaped: further kinds a case file can use, each reported with its own recall.
eval:import-aacr builds a case file from the public AACR-Bench data set (see Benchmark).
What it measures
Section titled “What it measures”A finding matches a label when it is on the same path and, for a label with a line, on the same side and within 3 lines (or the label’s own tolerance). Each finding matches at most one label and each label at most one finding, choosing the matching that covers the most labels. Findings of severity major or blocker count as blocking. Rates are over the cases that ran without failing; failed cases are counted and costed, not scored.
| Metric | Meaning | Better |
|---|---|---|
valid_recall |
Share of valid labels matched by a finding. |
Higher |
valid_blocking_kept |
Share of blocking valid labels matched by a blocking finding. |
Higher |
invalid_repeat_rate |
Share of invalid labels the engine repeated. |
Lower |
invalid_blocking_rate |
Share of invalid labels repeated as a blocking finding. |
Lower |
escaped_recall, first_recall, late_recall |
Recall on labels of those kinds. | Higher |
comments_per_case, blocking_per_case |
Findings, and blocking findings, per case. | |
zero_comment_rate |
Share of cases with no finding at all. | |
failed_cases |
Cases that failed. | Lower |
total_cost |
Cost of every case, failed ones included. | Lower |
median_duration_s |
Median seconds per case. | Lower |
The summary also counts the labels of each kind, so you can see how much each rate rests on.
Compare runs
Section titled “Compare runs”eval:compare prints the two runs side by side, with the change in each metric marked better or worse:
npm run eval:compare -- ../runs/baseline/summary.json ../runs/first/summary.json --noise ../runs/baseline-2/summary.jsonWith --noise, pass a second run of the baseline. A change no larger than the distance between the two baseline runs is marked noise instead. Models are not deterministic, so run the baseline twice before you trust a small difference.
The comparison refuses two runs made on different case files (different_case_files). It warns when the case counts differ, when a run was stopped early, and when either run has failed cases.
What a replay leaves out
Section titled “What a replay leaves out”- Extension modules. The replay loads none, so it runs without extension context and without acceptance rows. A config that names modules still needs the variables their options name to be set.
- MCP servers. The replay opens none, so it runs without tools. This is deliberate: a replayed pull request is merged, and a documentation server’s index may already hold its fix. A config that names servers still needs the variables their headers name to be set.
- Memory. The replay runs without memory and takes no
--memory. Without--lessonsit is shown no lesson, and it is given the time of the run as its clock.
The replay honours model.toolChoice.
The replay with lessons
Section titled “The replay with lessons”With --lessons <lessons.json>, each case is reviewed as of its date, with the lessons the file holds that were live then (see Measuring lessons). The file is the one eval:judge-replies writes. It must be outside the project folder, and a file that is not whole is refused (lessons_incomplete).
npm run eval:lesson-cases -- --history ../history.jsonl --findings ../export.jsonl --lessons ../lessons/lessons.json --out ../lesson-cases.jsonlnpm run eval:replay -- --cases ../lesson-cases.jsonl --lessons ../lessons/lessons.json --out ../runs/on-1 --label on-1 --config config.local.ymlThe date of a case is its review_at, the start of the run it was made from, and it is the clock the review is given. A case is never shown a lesson made from its own pull request, nor one made from a reply written on its own day, nor one that has expired.
Dated case files only
Section titled “Dated case files only”eval:lesson-cases writes a review_at into every case. A replay with --lessons refuses a case file in which a case it would run has none (case_without_date). Without a date, a case could be shown a lesson made from itself or from a reply written after it, and a case file with no dates predates every lesson anyway. --lessons cannot be combined with --plain (usage: --lessons cannot be used with --plain).
Lessons alone
Section titled “Lessons alone”The memory of a replay with lessons holds no signal and no revert, and its results hold no block scores. To measure what lessons do to the score, use the backtest (see Lessons in a backtest).
What it records
Section titled “What it records”Each row of results.jsonl carries lessons: the case’s status, code and number of lessons shown, or null. summary.json names the lessons file and its sha256 and counts the cases by status. summary.md ends with a line Lessons: as of each case, from <file>. Cases shown a lesson: ...; with none to show: ...; not shown: ...; failed: ...; not asked: ....
Comparing runs with lessons
Section titled “Comparing runs with lessons”eval:compare refuses two runs that both have lessons and were shown different ones (different_lessons). When a run has lessons, it ends with a line lessons: <file>; <file> naming each run’s file, with none for a run without. It needs the same case file for both runs, as always, so run the baselines on the dated case file, without --lessons.
Before you pay for a run
Section titled “Before you pay for a run”A replay with lessons makes the same paid calls as one without, and needs GITHUB_TOKEN like any replay. Run the count first: eval:lesson-cases is free, and tells you whether the cases hold enough lessons and invalid labels to show anything.
Two things to keep in mind when you read the results: a lesson a team switched off in the deployment is shown anyway, and the lessons are the eval’s own (see Measuring lessons).