Agent Playground
Recipe: Fix until tests pass
Writes a function, runs the tests, fixes what failed and runs them again until they pass. What it does, when to use it, how to make it yours, and what a run costs.
Runs a project's tests, and when they fail, fixes the code and runs them again, until they pass or the loop limit is reached. It's the simplest useful loop, and the shape behind most "keep at it until it works" jobs.
| At a glance | Notes |
|---|---|
| Category | Coding |
| Shape | A loop |
| Plan | Free and up |
| Needs a Claude key | No |
| Limits it comes with | 5 loops, 180 seconds, $0.05 |
When to use it
- You have a check that says pass or fail (tests, a linter, a script that validates a file) and something that can make the next attempt better.
- You want an AI agent to keep fixing code until the tests are green, with a cap on how many tries it gets.
- You're learning the Playground: this is the recipe to start with.
Run it
- Open Agent Playground in the dashboard and find Fix until tests pass under Start from a recipe. 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.
- Choose Simulate to see the forecast, then Run.
What you'll see: Run tests fails three times, each time with fewer failures (1 passed, 3 failed, then 2 passed, then 3 passed), and passes on the fourth try. The panel groups the steps by First pass, Loop 1, Loop 2 and Loop 3, and Save result packs the working code into result.tgz.
Make it yours
- Change Set up project to get your own code, for example
git clone https://github.com/you/app proj && cd proj && pip install -r requirements.txt. For a private repository, save a token under Policies → Secrets first. - Change Run tests to your test command:
pytest -q,npm test,go test ./.... - Replace Fix failures with an Agent. Set its Goal to
The tests in proj fail. Fix the code so they pass. Don't change the tests., use Insert… to add the output of Run tests, and set Check that it worked to your test command. You'll need your Claude key. - Change Save result to whatever should happen with working code: package it, open a pull request, or add an Approval first.
- Open Limits and set Loops to how many tries you'd accept (3 to 5 is typical with an agent), and Spend to cover the agent's Claude use.
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.0002 | $0.0004 | $0.0023 |
| How long it takes | 20 seconds | 35 seconds | 180 seconds |
A typical run uses $0.0002 of sandbox time, so about 4,000 runs cost $1, and every plan includes $5 of usage a month. At most is the most a run could cost with these limits: it stops at $0.05 or 180 seconds, whichever comes first.