Recipe: Three agents race, tests pick
Copies a project into three sandboxes, gives each a differently told agent, and keeps the passing fix with the fewest changes. What it does, when to use it, how to make it yours, and what a run costs.
Copies one project into three sandboxes and sets an agent loose in each, told to work a different way: the smallest fix, a clean rewrite, or the rules first. A score step in each lane runs the tests and counts changed lines, and the judge keeps the lane that passes with the fewest changes. The losers' sandboxes are deleted.
| At a glance | Notes |
|---|---|
| Level | Advanced |
| Category | Coding |
| Shape | Forked sandboxes, an agent in each, a judge |
| Plan | Pay as you go (runs 4 sandboxes at once) |
| Needs a Claude key | Yes |
| Limits it comes with | 1 loop, 900 seconds, $1.00 |
| Claude key limit for a run | $1.00 of Claude |
Opens it in the Playground as a flow of your own. Simulate shows what a run costs. Run asks before it starts.
The steps
| Step | Block | What it does |
|---|---|---|
| Set up the project | Run command | Writes a small shopping-cart module with three pricing bugs and five tests, and commits it so changes can be counted. |
| Fork ×3 | Try in parallel | Copies the sandbox into lanes A, B and C. |
| Smallest fix | Agent | Lane A: an agent fixes it with the smallest change it can. |
| Clean rewrite | Agent | Lane B: an agent rewrites the functions cleanly. |
| Rules first | Agent | Lane C: an agent writes down the rules first, then fixes. |
| Score lane A, B, C | Run command, one per lane | Each lane's score: 100 for each passing test, minus 1 for each changed line, printed as {"score": ...}. |
| Highest score | Keep the best | Keeps the lane with the highest score. |
| Keep the winner | Run command | Shows the winning change and saves it as shop/winning.patch. |
When to use it
- You don't know which approach, prompt or model will solve a task, and trying them one after another is slow.
- You want the winner picked by tests and numbers, not by taste.
- Each try must not see or break the others.
Run it
The quick way: choose Try it now under the drawing. It opens the recipe in the Playground as a flow of your own, after you sign in if you aren't yet. Simulate opens it and shows the forecast, and Run opens it and asks before it starts, with what the run will likely cost. From the dashboard instead:
- In the dashboard sidebar, open Agent Playground → Recipes and find Three agents race, tests pick. Choose Advanced to filter the list. In the builder, Recipes in the toolbar lists them too.
- Choose Use this recipe. It becomes a flow of your own, so changing it never changes the recipe.
- If you haven't yet, save your Claude key on the Secrets page. The builder offers Add a key… in the step's key list if it's missing.
- Choose Simulate to see the forecast, then Run.
What you'll see: The three agents work at the same time, each in its own sandbox. Open each lane's score step to compare them. The judge keeps one, and Keep the winner shows its diff.
Make it yours
- Clone your repository in Set up the project instead of writing the sample, and change the test command in
.qr/score.py. - Give each agent a different goal, model or turn limit. Each agent's caps are on its step, under It stops at whichever comes first.
- Change the score: for example passing tests minus seconds taken, or a benchmark's number. The judge reads the last JSON line each lane prints.
- The flow's key limit caps all three agents together at $1 a run. The Policy panel shows it; change it in the flow's JSON under
policy.keyBudgets.
What a run costs
These are the builder's own forecast for the recipe as it comes, with its limits, rounded. Simulate shows the same numbers for your version, and they change as you change the flow.
| Notes | Typical | 1 in 10 runs | At most |
|---|---|---|---|
| Sandbox time | $0.006 | $0.008 | $0.04 |
| Claude, on your key | $0.21 | $0.34 | the run's spend limit |
| How long it takes | about 2 minutes | about 3 minutes | 900 seconds |
A typical run uses $0.006 of sandbox time, so about 180 runs cost $1, and every plan includes $5 of usage a month. That includes all 4 sandboxes: the main one and each lane. Claude is billed by Anthropic to your own key, at their usual prices. The run counts it toward its spend limit, so it can't overspend, but we don't charge you for it. At most is the most a run could cost with these limits: it stops at $1.00 or 900 seconds, whichever comes first.