Manuscript Offprint

arXiv:2610.18755

PreciseCoder: Faithful and Generalizable Debugging Beyond Unit-Test Rewards

Yunkai Zhan, Miaosen Chai, Shangshang Wang, Jike Zhong, Yuqing Yang, Deqing Fu, Serina Chang, Wang Bill Zhu

ABSTRACT

Reinforcement learning (RL) from unit tests is the common recipe for post-training code models, but a unit test only asks whether the final program passes. We analyze what this unit-test-only reward teaches a model during debugging and find that, while it raises pass rates, it also teaches the model to edit more and to hallucinate bugs in code that is already correct. We introduce PreciseCoder, a training algorithm that augments the unit-test reward with a signal for semantically verified, localized edits, which correlates with smaller edits and higher pass rates. On 4B, 9B, and 27B models, PreciseCoder reduces the average number of edit lines from 7–15 to 3 at a pass rate on par with unit-test-only training. Trained only on single-line bugs, PreciseCoder can generalize to repository-level program repair, where it resolves more issues with smaller patches. Its precision also transfers from weaker to stronger models: given the reasoning trace of a 9B PreciseCoder model, frontier models such as GPT-5.6 Sol and Qwen3.8-Max gain 4.6–12.4 points in edit precision with no additional training. Linguistic analysis of the thinking traces shows that our reward encourages the model to reason about individual lines, name the buggy ones, and form consistent bug hypotheses.

1 INTRODUCTION

LLMs are increasingly integrated into programs and workflows because they are trained on vast amounts of code. When a developer hands a model a broken function, they want it to identify and repair the fault without modifying code that is already correct. Yet even frontier LLMs rewrite code that was not broken: on PDB (Zhu et al., 2026b), GPT-5.1-Codex passes 76% of tasks, yet only 40% of the lines it edits are necessary. This over-editing is costly (Figure 1a). Reviewers must inspect every changed line, so the cost of reviewing a repair grows with the size of the edit rather than the size of the bug; even merged pull requests produced by coding agents need human revision 45% of the time (Watanabe et al., 2025). Rewrites can also introduce behaviors the tests do not cover, so a patch that passes every test can still regress (Qi et al., 2015; Smith et al., 2015; Ahmed et al., 2025).

Reinforcement learning from unit tests has become the dominant approach to post-training code models (Guo et al., 2025; Lambert et al., 2024; Luo et al., 2025; Yang et al., 2025b), so we ask whether it is a root cause of over-editing. We first audit what the unit-test reward teaches by tracking the edit statistics of GRPO (Shao et al., 2024) training rollouts and measuring how each candidate reward term correlates with correctness on the same rollouts. We find the unit-test reward raises pass rates without restraining unnecessary edits, and as training proceeds it increasingly makes the model hallucinate bugs in code that is already correct (Figure 1b). Prior work counters over-editing by penalizing edit distance to the reference (Ke et al., 2026; Zhu et al., 2026a) or by imitating minimal patches (Yang et al., 2026; Dai et al., 2025; Luo et al., 2026), but edit size is only weakly correlated with passing the tests, so optimizing it trades pass rate for smaller edits.

We propose PreciseCoder, which augments the unit-test reward with the semantically verified precision and recall on edits, combined into an F1F_{1} score. Unlike edit size, this score correlates with

Over-editing

Input: buggy program

5 for x in set(nums):

6 d[x] += 1

7 d[x + k * 2 + 1] -= 1

8 return max(accumulate(d))

LLM

Output: over-edited

5 for x in nums:

6 d[x] += 1

7 d[x + k * 2 + 1] -= 1

8 max_val = 0

9 current_val = 0 ...

tests pass

7 edits, 1 needed

Precise fix: 1 line

Bug hallucination

Input: correct code

4 def task_func(L):

5 ...

6 mean = np.mean(flattened)

7 va = np.var(flattened)

LLM

Output: "fixed", now wrong

4 def task_func(L):

5 ...

6 mean = np.mean(flattened)

7 va = np.var(flattened, ddof=1)

Precise answer: return unchanged

(a)

Figure

(b)

Figure

Figure 1: (a) Illustration of over-editing and bug hallucination phenomenon; (b) Training dynamics of GRPO vs. PreciseCoder on Qwen3.5-4B, reach the same pass rate (left), but GRPO edits more lines (middle) and leaves fewer bug-free programs untouched (right).

both the unit-test outcome and the edit size. Hence, the two terms can be optimized together, and we normalize them separately inside the group-relative optimizer. Across Qwen3.5-4B, Qwen3.5-9B and Qwen3.6-27B, PreciseCoder raises edit precision by 24–29% over the base models and by 26–35% over unit-test-only GRPO, cuts the average edit size from 7–15 to 3 lines per task, and keeps pass rate on par with unit-test-only GRPO. The same reward suppresses bug hallucination although training never shows a correct program: on correct code input, the no-edit (i.e., no operation) rate rises to 47–52%, against 31–37% for the base models and 19–31% after unit-test-only GRPO.

Trained only on single-file single-line bugs, the learned behavior generalizes to complex program repairs. On PDB-Wild multi-line and repository-level bugs, precision rises by 20, 17 and 20 points at 4B, 9B and 27B while the edit size shrinks by 63–71%. On SWE-Bench Verified, PreciseCoder resolves more issues without inflating its patches, and it breaks fewer repositories whose issue is already fixed. Trained with agentic RL in a five-turn editing agent, a 9B model reaches 67.4% edit precision at a 56.3% pass rate, the best of every 9B model in agentic debugging on both.

Precise debugging also transfers upward, to models we cannot train. Handing the reasoning trace of PreciseCoder-9B to five stronger receivers, among them GPT-5.6 Sol and Qwen3.8-Max, raises their edit precision by 4.6–12.4 points at their own pass rates, with no weight access, shared tokenizer or training. A linguistic analysis of the traces points to what travels: either reward makes the model think longer and quote the buggy lines, but only PreciseCoder encourages the model to reason about individual lines, form bug hypotheses, and weigh whether each edit is worth keeping.

Our contributions are threefold:

① Diagnosis. We show that unit-test-based reinforcement learning raises pass rates while increasing edit size, rewriting correct code, and hallucinating bugs in bug-free programs. We establish this by auditing edit statistics throughout training and measuring each reward term's correlation with correctness and with the number of edited lines when the unit tests pass.

② Fix. We augment the unit-test reward with semantically verified precision and recall. Across 4B, 9B, and 27B models, this reward trains stably, raises edit precision by 24–29 points, reduces the average number of edited lines to approximately three per task without sacrificing pass rate, and curbs bug hallucination, raising the no-edit rate on correct code from 31–37% to 47–52%.

Table 1: PreciseCoder vs. representative related work. “–” marks evaluation-only studies.

DiagnosisReward signalsGeneralizability
Over-editingBug hallucinationUnit testsEdit extentLocation verifiedPartial fixesWeak-to-strong
FixedBench (Gloaguen et al., 2026)✕✓----✕
PDB (Zhu et al., 2026b)✓✕----✕
SWE-RL (Wei et al., 2025)✕✕✕✕✕✕✕
EA-GRPO (Ke et al., 2026)✓✕✓✓✕✕✕
OverEdit (Zhu et al., 2026a)✓✕✓✓✕✕✕
PAFT (Yang et al., 2026)✓✕✕✓✕✕✕
AdaPatcher (Dai et al., 2025)✓✕✓✓✕✕✕
RECAP (Luo et al., 2026)✓✕✕✓✕✕✕
PreciseCoder✓✓✓✓✓✓✓

③ Generalization. The precision carries to multi-line, repository-level and agentic debugging and to SWE-bench Verified, and it travels through the reasoning trace alone: a 9B donor raises the edit precision of frontier models by 4.6–12.4 points. What travels, per a linguistic analysis of the traces, is naming the buggy line and weighing each edit.

References (51)