Repair Loop
A weekend project, September 2026 · code
Repair Loop asks a language model to fix a failing test, then lets something the model cannot touch decide whether the fix is right.
Why
A model asked to fix a failing test can make that test pass without fixing the bug, for example by special-casing the input the test uses. I wanted a loop where that does not count as success.
How it works
- Reproduce. Before any model runs, the public tests are run on the untouched code. If they pass, there is nothing to repair and the loop stops.
- Diagnose and plan. One model reads the failure output and a snapshot of the repository and names the likely cause. A second turns that into a short plan.
- Write patches. Two fixers work in parallel from the same plan with different instructions: one aims for the smallest root-cause fix, the other for a defensive one. Each returns a unified diff.
- Check the diff. Plain code rejects a diff that edits tests, touches a file outside the case's allowlist, renames a file, contains binary data or a symlink, or is too large (40 KB, 800 changed lines or 12 files).
- Run it somewhere else. The diff is sent to a GitHub Actions workflow. The runner checks it again, applies it to a clean copy of the case, and runs the tests in a Docker container with no network, a read-only filesystem, no Linux capabilities, a non-root user, and limits on CPU, memory and processes. Hidden tests run only if the public ones pass.
- Review. A critic model reads the patch next to the test results. If the tests passed and the critic accepts, a QA model makes the final call.
- Try again. If nothing is accepted, the last two critiques and test results go into the context and the loop starts over from diagnosis, for up to three rounds.
Each run has budgets (by default 24 model calls, 6 candidate patches and a $10 cost cap) and saves a checkpoint after every stage, so a stopped run can resume. No model is trained. Whatever improves between rounds comes from the evidence added to the prompt.
Choices I made
- The models never run anything. They return typed JSON, and only the orchestrator decides what happens next.
- Generated code never runs on my machine. Every test run happens on a disposable GitHub-hosted runner. That costs speed, since each check is a workflow run, and it makes the loop depend on GitHub being up. That mattered later.
- Hidden tests stay hidden. They live outside the folder the fixer sees. The models are told only whether they passed.
- Parts of the loop can be switched off. Four variants (single pass, retry only, diagnose then fix, full team) make it possible to see which parts earn their cost. Each role can also use a different model.
The benchmark
The repository includes 185 small Python projects, each with a bug, a public test that fails, and hidden regression tests. For 170 of them, the test suite checks that a reference fix passes both sets. For 159, it also checks that a shallow fix passes the public test and still fails the hidden ones.
A shallow fix looks like this. The public test checks one address, and this version handles exactly that address:
def canonical(address):
if address == "Ada+news@Example.com":
return "ada@example.com"
return address.lower()
What happened when I ran it
I have one overnight run: one model, 12 cases, all four variants. It is not a result I would defend, and the table shows why.
| Variant | Solved | What stopped the rest |
|---|---|---|
| Single pass | 8 of 12 | 4 runs hit a budget limit |
| Retry only | 8 of 12 | 4 runs hit a budget limit |
| Diagnose, then fix | 6 of 12 | 6 runs hit a budget limit |
| Full team | 0 of 12 | Every run failed on GitHub errors (HTTP 500 and 502) |
So the full loop, which is the configuration the project exists to test, has no result yet. The plumbing works: 273 verification jobs ran on GitHub Actions that weekend. The measurement does not exist.
What I would do next
- Run all four variants on the full benchmark, several times each.
- Count budget stops and infrastructure errors separately from wrong patches. The leaderboard currently counts all three as failures.
-
Check the benchmark itself more carefully. One case shipped with a
module named
email.py, which shadows Python's standard library. It broke the test suite in CI and I did not notice until November.
Limits
- Passing tests is evidence that a patch is right, not proof.
- The container shares the runner's kernel, so the isolation is weaker than a separate virtual machine for each patch.
- The cases are small and synthetic. They say little about repairs in a large codebase.