Many code-writing systems now work in a loop. A model writes a program, a separate "tester" writes unit tests, the tests are run, and failures are fed back so the model can fix its code. This loop works well when a large proprietary model plays every role. It breaks down on open models under about 13B parameters, and even strong loops stop improving after two to four rounds. We think a single under-measured quantity explains much of both failures. When one model writes both the code and the tests, the tests tend to miss exactly the bugs the code contains. The same model has the same blind spots in both roles, and a loop cannot repair a bug that no test catches.
We propose to fine-tune a 7B open model to play coder and blind tester, where the tester is trained specifically on tests that fail the model's own typical wrong programs. We also mix in general instruction data at controlled ratios so the model keeps its non-coding abilities. The main quantity we measure is the escape rate: the fraction of the model's wrong programs that pass every test the model itself wrote. We then ask whether lowering it, rather than improving the repair step, is what lifts the loop's accuracy and pushes back the plateau.
Core Claim
Consider a coder–tester loop run by one small model. Let a wrong program be one that fails a large held-out test suite. The -ET extended suites of HumanEval and MBPP serve as the source of truth. Define
$$E = \Pr\big[\text{program passes all model-written tests} \mid \text{program is wrong}\big].$$
Each refinement round can only act on the fraction $1-E$ of wrong programs whose failure is detected. Final gains are therefore bounded by roughly $(1-E)$ times the repair success rate. Our claim is that for small models trained in the usual way, $E$ is high. It is also much higher than the escape rate against tests written by an unrelated model, which shows that coder and tester errors are correlated.
We further claim that $E$ can be lowered directly by one change in how the tester's training data is chosen. The tester should be trained on discriminating tests: tests that pass the reference solution and fail programs sampled from the coder. Tests that are merely correct do not do this. Lowering $E$ should raise loop accuracy more than an equal amount of extra repair-trajectory data would. It should also let gains continue past the two-to-four-round plateau reported by Yan et al..
The contribution is not "distill a multi-agent system into one model," which has been done. The contribution is to name and measure the specific property that makes role separation valuable, namely that the tester's errors are independent of the coder's. We then target that property with a data-selection rule, and treat the mixing ratio between roles as the main training variable.
How this relates to prior work
Two prompt-only systems motivate the proposal. AgentCoder keeps the test designer blind to the code and runs tests in a deterministic executor. This breaks the confirmation bias of self-critique and reaches 96.3% pass@1 on HumanEval with GPT-4. Self-collaboration Code Generation via ChatGPT runs an Analyst–Coder–Tester team from one base model. It reports that the protocol collapses below about 13B parameters. Both show that separation helps, but neither measures why, and neither trains weights. We borrow AgentCoder's quarantine of the tester, keeping it blind to the code, and ask what training makes that quarantine effective in a small model.
A second group of papers distills multi-agent behavior into one model. AgentArk distills debate for math and question answering. Chain-of-Agents trains an agent model up to 32B with internal planning and verification roles, cutting tokens by 84.6% relative to multi-agent systems. COAST uses an agent society only to generate debugging data for a single debugger model. MoRAgent gives each role its own lightweight adapter for tool calling. None of them grounds a tester role in execution against the student's own failure distribution, and none measures whether the distilled roles share blind spots. Chain-of-Agents in particular suggests one model can host several roles cheaply. Our proposal asks whether hosting both roles in one model silently correlates their errors.
Several papers supply methods we reuse. LeDex supplies execution-verified debugging trajectories built from APPS, CodeContests and MBPP. It also shows that explaining the bug before patching helps; on MBPP, StarCoder-15B gains 15.92% pass@1 from SFT and up to 3.54% more from RL. AgentRefine supplies loss masking, where the training loss is computed only on the post-error reasoning and the corrected action. Its "death loop" observation also gives us a second failure mode to track.
The mixing direction constrains the design. Demystifying Instruction Mixing shows that code data added to general chat slightly improves alignment. On LLaMA-2-7B the FLASK alignment score is 61.2 for chat plus code versus 60.6 for chat alone. The same paper shows that rigid task-format data hurts alignment, dropping it to 45.8 for P3 alone. That paper is also the source of the heuristic that specialized data should be about 1.5 times the general data. Test-writing data is rigid and templated in the same way as P3, so we treat its share of the mixture as a risk to measure rather than a free knob.
One contradiction must be faced directly. Agentless shows that a fixed pipeline, which localizes the fault, writes a patch and validates it with generated reproduction tests, beats multi-agent systems on SWE-bench Lite (32.00% versus MAGIS's 25.33%). We read this as consistent with our claim rather than against it. What matters there is the generated validation test, not the conversation between agents. Our work is effectively about how good such tests are when a small model writes them.
Research Program
We start from a 7B open code model. We build three data pools from the APPS, CodeContests and MBPP training splits.
The first pool is coder refinement trajectories. Each trajectory contains a problem, a program, and the failing test output, followed by an explanation and a fixed program. These are built in the LeDex style, verified by execution, and trained with AgentRefine-style loss masking.
The second pool is tester data. It contains a problem statement only, with no code, and a target set of test cases. Expected outputs always come from running the reference solution, so every test is correct by construction. We build two versions of this pool.
- Generic version: tests are sampled from a teacher model and kept if they are correct.
- Discriminating version: candidate inputs are generated, then a test is kept only if it passes the reference solution and fails at least one wrong program sampled from the current coder. Sets are then selected greedily to kill as many distinct wrong programs as possible.
After the first round of coder training, the coder's error distribution changes. We therefore re-mine the discriminating tests once against the updated coder, and measure whether this second round matters.
The third pool is general instruction data, meaning chat data of the Alpaca type, to protect conversational ability.
We cross four factors:
- Tester data: generic versus discriminating.
- Role parameterization: one shared fine-tune with role prompts, versus a separate adapter per role (a stripped-down MoRAgent with no router, since the role is always known).
- Mixing ratios: the tester-to-coder ratio and the specialized-to-general ratio, including the 1.5x point.
- Refinement budget: one to eight rounds.
At inference, the tester sees only the problem statement. Its tests run in a sandbox, and failures return to the coder, following AgentCoder's protocol exactly.
For every trained model we measure the escape rate $E$ on HumanEval, MBPP, HumanEval-ET, MBPP-ET and LiveCodeBench, using the -ET or hidden suites to label programs wrong. As a reference point, we measure the escape rate of the same coder's wrong programs against tests written by an unrelated model family. The gap between the two escape rates is our operational measure of shared blind spots.
Baselines
Naive reference. The base 7B model with one-shot generation, together with the same model prompted into AgentCoder's roles without any fine-tuning. The file lets us predict the second will be weak: Self-collaboration reports persona collapse below 13B. We measure it anyway to confirm that fine-tuning is necessary.
Strongest open-model competitor. LeDex-style single-model self-debugging: SFT on the same verified refinement trajectories and the same token budget, with the model repairing from execution feedback against the benchmark's visible tests. Its published MBPP numbers are the gains quoted above, and its fix rate on buggy code rises from 6.4% to 17.5%. We rerun it on our backbone with identical data, steps and hyperparameter search budget. To beat it, our loop must achieve higher pass@1 on MBPP-ET and HumanEval-ET at equal inference tokens and without access to visible tests.
Mixed-data comparison. On DEBUGEVAL, NeuDebugger reaches an overall score of 54–56% at 6.7B and 8B, per COAST. We treat that as the bar for debugging skill, to check that training the tester does not cost the coder its repair ability.
Ceiling reference. AgentCoder with GPT-4 reports 91.8% on MBPP-ET against 52.2% for zero-shot GPT-4. We use this as a ceiling rather than a target. We found no reported result on Lacuna for a fine-tuned open 7B blind-tester loop on MBPP-ET.
Key ablation. The generic-versus-discriminating tester arm, with everything else held fixed. If the discriminating arm does not lower $E$, and does not raise loop accuracy by more than adding the same number of extra coder trajectories would, the central claim fails.
Alignment retention. FLASK scores against the base model and against a chat-only fine-tune. The chat-plus-code value of 61.2 reported by Demystifying Instruction Mixing is an external reference point, though the backbone differs.
Why not just…?
Why not just sample many programs and pick one, at the same compute? This is the most serious threat. If the loop's benefit is only extra samples, a compute-matched best-of-n would match it. We rank the n samples by agreement with the model's own generated tests, and give this baseline the same total tokens as the loop. Note that such ranking also depends on the tests catching wrong programs, so escape rate limits it too. We expect discriminating tests to help both methods, and report whether the loop adds anything beyond better ranking. If it does not, we will report the result as "train better testers," which is still a useful finding.
Why not just train one self-debugging model and skip roles, as LeDex does? LeDex's loop repairs against visible tests or errors that are given to it. It never has to find bugs that no one has flagged. The test-free setting is where escape rate matters. The LeDex baseline above, run on identical data, settles the question: if it matches us on the -ET suites, roles add nothing.
Why not just prompt the small model into roles? Self-collaboration reports that personas collapse under 13B. COAST reports that small models label up to 98% of errors as generic "logical errors." Our prompt-only arm directly tests whether this holds on a modern 7B.
Why not an Agentless-style fixed pipeline? Agentless's validation step already is a blind tester. Our work does not compete with the fixed pipeline; it improves the component that pipeline depends on. As a stretch goal, we would swap our tester into an Agentless-style run on SWE-bench Lite and check whether its 32.00% moves.
Why not just use separate adapters so the roles share no parameters? The separate-adapter arm tests exactly this. We expect the adapters to share the backbone's blind spots, so parameter separation alone should shrink the escape-rate gap much less than changing what the tester is trained on.
Proposed Experiments
The decisive checks are four.
- Correlated blind spots exist. Shared-model escape rates should be clearly higher than escape rates against an unrelated tester model. If they are not, the premise is wrong and we stop.
- Discriminating data lowers escape rate. Discriminating tester data should lower $E$, and loop pass@1 on MBPP-ET, HumanEval-ET and LiveCodeBench should rise roughly in proportion to $1-E$. Compared at equal data volume, this gain should exceed the gain from adding more coder trajectories.
- The plateau shifts. When $E$ is plotted against round number, rounds beyond three should still add accuracy under discriminating testers but not under generic ones. This would tie the plateau reported by Yan et al. to detection rather than repair. We also count repeated-hunk "death loops" in each arm.
- The mixture is safe. Across the mixing sweep, we report where FLASK alignment begins to fall as the share of rigid test-writing data grows, and whether general data at the 1.5x point recovers it without raising $E$.
All comparisons use matched inference tokens and report token counts. This lets the reader judge the cost of the extra role against the 4.5x token overhead reported for Adversarial Review.
References
- CodeTransOcean: A Comprehensive Multilingual Benchmark for Code Translation
- AgentCoder: Multi-Agent-based Code Generation with Iterative Testing and Optimisation
- Self-Collaboration Code Generation via ChatGPT
- AgentArk: Distilling Multi-Agent Intelligence into a Single LLM Agent
- Chain-of-Agents: End-to-End Agent Foundation Models via Multi-Agent Distillation and Agentic RL
- Enhancing the Code Debugging Ability of LLMs via Communicative Agent Based Data Refinement
- MoRAgent: Parameter Efficient Agent Tuning with Mixture-of-Roles
- LeDex: Training LLMs to Better Self-Debug and Explain Code
- AgentRefine: Enhancing Agent Generalization through Refinement Tuning
- Demystifying Instruction Mixing for Fine-tuning Large Language Models
- Agentless: Demystifying LLM-based Software Engineering Agents
- Adversarial Review: Structured Disagreement for Grounded Agentic Code Review