Skip to main content
Run the same task more than once and keep the attempt that scores highest. Use it when a task has several defensible answers and you’d rather compare than iterate: an implementation with a few plausible designs, a draft with a few angles. When one attempt and a reviewer will do, use a writer and a reviewer. A tournament is an eval that picks a winner: the judge is a function over the files each candidate left, not a model’s opinion.

Shape

The tournament

tournament takes the number of candidates, a function from the candidate index to a job, and a judge. Each candidate runs in its own worktree on its own branch:
examples/tournament.ts (excerpt)
Every candidate writes src/retry.ts and a test, then runs the test with Node. A failed test fails the candidate. The judge reads each passing candidate’s source and scores it:
examples/tournament.ts (excerpt)
One point for passing, one for a named attempts cap, one for stopping when the caller aborts. The source on disk is the evidence, not the candidate’s outcome data. A candidate that throws is never scored, so it can’t win whatever its source looks like. The highest score lands on main; a tie goes to the first candidate, so give the judge enough resolution to separate the attempts you care about. Every candidate’s worktree and branch is removed when the tournament ends. concurrency sets how many candidates run at once, all of them by default.

What the run did

The candidates here are functions, so the file runs offline and always gives the same answer. Put an engine in the candidate job and the shape is a tournament of models. Run it with npx tsx tournament.ts:
Output
The third candidate wins. It’s the only one with both the attempts cap and the abort check, so it scores three. Its source is what src/retry.ts holds on main afterwards. The branch list is empty because the losers left nothing behind.
examples/tournament.ts

Next steps

  • Workspace: the worktree each candidate gets, and how the winner lands back.
  • Evals: what counts as an eval here, and where a judge that picks a winner sits among them.
  • Runtime: tournament and its options.