Fixed or Deleted? External Feedback Lets Cheaper AI Coding Agents Repair Rule Violations
Organizations: CodeAssure Labs, Singapore
Abstract
Many defects violate project rules that the code itself does not reveal, such as layering constraints or required tests. We study whether LLM coding agents repair such violations better when an external checker reports them, with their location and a repair goal. Three models, a small, medium and large model, driven by an AI agent, worked on 25 pull requests with 31 planted defects in ten open-source projects, plus 5 correct controls, five times alone and five times with findings from CodeAssure (CA), a commercial checker. We also compare with GitHub Copilot code review, and compare CodeAssure's detection with nine free static-analysis tools run out of the box, including Semgrep and SonarQube Community. Counting a run as repaired only when the repaired code also compiles and keeps its feature, CA findings raised the repair rate from 26% to 69% for the smallest model, from 46% to 90% for the medium model and from 45% to 93% for the largest model (pull-request-level p < 0.001), and from 39% to 84% over all runs. Every Java, TypeScript and Python repair compiled. We found that agents often cleared a defect by deleting a newly added file. Metrics based on whether the defect is gone count feature deletion as a success. The largest model alone did so in 44 of 125 runs. CA includes a check for deleted files that largely prevents this. In an ablation with the check turned off, removals rose from 9 to 65 out of 375 runs and the repair rate fell to 54% (small), 70% (medium) and 85% (large model). The CA workflow also outperformed Copilot code review (p < 0.001). Together, the free tools detected 8 of the 31 defects, and CA detected all 31. With CA, the medium model repaired 90% of runs, against 45% for the largest model alone, at about one fifth of the mean cost per run (0.91).
Figures & tables
| Class | Description | Example | PRs |
|---|---|---|---|
| Code-visible | Detectable from the code alone | A renamed function with callers left behind | 3 |
| Convention | A project-specific rule about what code may do where | Console output in service code, raw threads in the storage layer | 8 |
| Architecture rule | A declared layering or process constraint | A data-layer module importing a web route, a command without its required test | 9 |
| Multiple | Two or three defects from different classes | 5 | |
| Clean | No defect | 5 |
| Configuration | Build-checked | (cluster) | Static | Defect-gone rate | Removed | Cost per change |
|---|---|---|---|---|---|---|
| Haiku 4.5 alone | 26% [19, 34] | [11, 41] | 28% [21, 36] | 38% [30, 47] | 13 | $0.18 [0.14, 0.23] |
| Haiku 4.5 + CA | 69% [60, 76] | [54, 82] | 86% [78, 91] | 91% [85, 95] | 7 | $0.42 [0.31, 0.53] |
| Sonnet 5.5 alone | 46% [37, 54] | [28, 63] | 47% [39, 56] | 72% [64, 79] | 31 | $0.06 [0.06, 0.07] |
| Sonnet 5.5 + CA | 90% [84, 94] | [79, 99] | 94% [89, 97] | 96% [91, 98] | 2 | $0.17 [0.14, 0.19] |
| Fable 5.1 alone | 45% [36, 54] | [28, 62] | 45% [36, 54] | 80% [72, 86] | 44 | $0.91 [0.76, 1.08] |
| Fable 5.1 + CA | 93% [87, 96] | [83, 100] | 100% [97, 100] | 100% [97, 100] | 0 | $1.73 [1.32, 2.18] |
| A vs B | Repair rate: mean difference [95%] | A only / B only | p | Defect-gone rate: A only / B only | p |
|---|---|---|---|---|---|
| Haiku + CA vs Haiku alone | +58 pts [38, 74] | 77 / 5 | <0.001 | 72 / 6 | <0.001 |
| Sonnet + CA vs Sonnet alone | +47 pts [28, 66] | 62 / 3 | <0.001 | 33 / 3 | 0.014 |
| Fable + CA vs Fable alone | +55 pts [38, 72] | 69 / 0 | <0.001 | 25 / 0 | 0.016 |
| Sonnet + CA vs Fable alone | +50 pts [33, 66] | 62 / 0 | <0.001 | 25 / 5 | 0.062 |
| Haiku + CA vs Fable alone | +41 pts [20, 60] | 59 / 8 | 0.001 | 25 / 11 | 0.27 |
| Configuration | Code-visible | Convention | Architecture rule | Multiple |
|---|---|---|---|---|
| Haiku 4.5 alone | 15/15 | 11/40 | 5/45 | 4/25 |
| Sonnet 5.5 alone | 15/15 | 20/40 | 19/45 | 5/25 |
| Fable 5.1 alone | 14/15 | 21/40 | 13/45 | 8/25 |
| Haiku 4.5 + CA | 11/15 | 38/40 | 35/45 | 23/25 |
| Sonnet 5.5 + CA | 15/15 | 40/40 | 41/45 | 22/25 |
| Fable 5.1 + CA | 15/15 | 40/40 | 45/45 | 25/25 |
| Configuration | Repair rate | (cluster) | Defect-gone rate | Removed | 2nd session | Cost per change |
|---|---|---|---|---|---|---|
| Haiku 4.5 + CA, check off | 71% [63, 78] | [57, 84] | 86% [79, 91] | 19 | 33 | $0.37 [0.28, 0.46] |
| Haiku 4.5 + CA | 86% [78, 91] | [75, 94] | 91% [85, 95] | 7 | 41 | $0.42 [0.31, 0.53] |
| Sonnet 5.5 + CA, check off | 74% [65, 81] | [58, 87] | 97% [92, 99] | 29 | 19 | $0.14 [0.12, 0.15] |
| Sonnet 5.5 + CA | 94% [89, 97] | [86, 100] | 96% [91, 98] | 2 | 46 | $0.17 [0.14, 0.19] |
| Fable 5.1 + CA, check off | 86% [79, 91] | [73, 98] | 100% [97, 100] | 17 | 7 | $1.22 [1.01, 1.45] |
| Fable 5.1 + CA | 100% [97, 100] | [100, 100] | 100% [97, 100] | 0 | 18 | $1.73 [1.32, 2.18] |
| Configuration | Left alone | Unnecessary code edit | Feature removed | Mean lines changed | Cost per change |
|---|---|---|---|---|---|
| Haiku 4.5 alone | 9 | 16 (64%) | 0 | 7.8 | $0.11 |
| Sonnet 5.5 alone | 0 | 25 (100%) | 0 | 8.5 | $0.06 |
| Fable 5.1 alone | 0 | 20 (80%) | 5 | 21.6 | $0.73 |
| Each model + CA | 25 | 0 | 0 | 0.0 | 0.27 |
| Model | Steps, alone / with | Runs with a second session | Cost per change, alone / with |
|---|---|---|---|
| Haiku 4.5 | 43 / 60 | 41 of 125 | 0.42 |
| Sonnet 5.5 | 12 / 16 | 46 of 125 | 0.17 |
| Fable 5.1 | 22 / 34 | 18 of 125 | 1.73 |
| Language | Checked | Do not compile | Removed in place or stub | Failed with +CA |
|---|---|---|---|---|
| Java | 51 | 0 | 0 | 0 of 15 |
| TypeScript | 30 | 0 | 0 | 0 of 15 |
| Python | 202 | 0 | 21 | 8 of 70 |
| C++ | 305 | 16 | 2 | 8 of 137 |
| Rust | 263 | 34 | 2 | 19 of 113 |
| Total | 851 | 50 | 25 | 35 of 350 |
| Model | Workflow | Static scorer | Build-checked |
|---|---|---|---|
| Haiku 4.5 | Alone | 35 (28%) | 32 (26%) |
| +CA | 107 (86%) | 86 (69%) | |
| +CA, deletion check off | 89 (71%) | 67 (54%) | |
| Copilot review | 29 (40%) | 23 (32%) | |
| Sonnet 5.5 | Alone | 59 (47%) | 57 (46%) |
| +CA | 118 (94%) | 113 (90%) |
| Model | Workflow | Repair rate | Removed | Clean: code edits | Paired vs CA |
|---|---|---|---|---|---|
| Haiku 4.5 | Alone | 28% [21, 36] | 13 | 16 / 25 | 77 / 5, p < 0.001 |
| Haiku 4.5 | + Copilot | 40% [30, 52] | 13 | 12 / 15 | 38 / 5, p < 0.001 |
| Haiku 4.5 | + CA | 86% [78, 91] | 7 | 0 / 25 | |
| Sonnet 5.5 | Alone | 47% [39, 56] | 31 | 25 / 25 | 62 / 3, p < 0.001 |
| Sonnet 5.5 | + Copilot | 46% [35, 57] | 9 | 12 / 15 | 37 / 1, p < 0.001 |
| Sonnet 5.5 | + CA | 94% [89, 97] | 2 | 0 / 25 |
| Tool | Languages | In scope | Detected | Missed in scope | Not covered | Not caught (of 31) |
|---|---|---|---|---|---|---|
| CA | all five | 31 | 31 b | 0 | 0 | 0 |
| Rust build and Clippy | Rust | 10 | 6 | 4 | 21 | 25 |
| Semgrep | all five | 31 | 2 | 29 | 0 | 29 |
| Pylint | Python | 7 | 1 | 6 | 24 | 30 |
| SonarQube Community | Python, TypeScript, Java | 9 | 1 | 8 | 22 | 30 |
| Ruff | Python | 7 | 0 | 7 | 24 | 31 |
AI Coding Agents
AI coding agents use language models and software tools to plan, edit, test, and maintain code with varying levels of autonomy.
See all 365 papers