arXiv(opens in a new tab)cs.SESep 2026Cited by 3 papers on PaperVantage

Manuscript Offprint

arXiv:2609.04061

When Models Edit Too Much: On the Fidelity of Minimal Code Edits

Tongyao Zhu, Wei Hern Lim, Min-Yen Kan

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Large language models (LLMs) are increasingly used to edit existing code, but correctness alone is not enough: useful repairs should also be minimal, reviewable, and faithful to the original implementation. We study over-editing, the tendency of a model to rewrite code beyond what is required to fix a bug. We construct an evaluation framework from 400 BigCodeBench problems by injecting controlled AST-level corruptions into reference solutions, giving each repair task a known minimal patch. Across frontier LLMs, over-editing is widespread even among strong models like GPT-5.5: high Pass@1 can coexist with unnecessarily large edits and added cognitive complexity. A preservation instruction substantially reduces this behavior, lowering average excess Levenshtein distance from 0.195 to 0.131, reducing added cognitive complexity by 26.6%, and increasing Pass@1 by 2.3 points. However, these gains do not simply follow from a larger reasoning budget or larger models. We next ask whether minimal editing can be learned directly during post-training. We observe that supervised fine-tuning overfits to seen corruption patterns, whereas reinforcement learning gives the best out-of-domain edit-fidelity and performance-retention trade-off. These results position edit fidelity as a distinct axis of code-repair quality and show that it can be measured and learned.¹

1 Introduction

Software engineering is one of the main practical use cases for frontier LLMs, including systems explicitly optimized for coding assistance (OpenAI, 2025a; Anthropic, 2025b). In actual development workflows, developers need more than patches that execute correctly; they need patches that are easy to review, preserve the original intent of the code, and

Figure

Figure 1: A one-line off-by-one bug in a BigCodeBench function, repaired by a minimal patch and by six frontier models. Every patch passes the task's five tests: the minimal fix changes a single line, while GPT-5.4 adds 60 lines of input validation, dtype coercion, NaN masking, and resampling that no test requires. Other models gives median changes over five completions on the identical input, for models whose completions all pass the test cases.

avoid introducing new complexity. This requirement is especially important in brownfield settings, where the model edits an existing implementation rather than generating a new one from scratch. In such maintenance work, keeping patches minimal reduces review burden, avoids diff churn, preserves implicit design choices, and lowers the risk of regressions outside existing tests.

A model can successfully fix a bug while still rewriting much more of the function than necessary. We refer to this behavior as over-editing: a functionally correct repair that changes more code than the minimal fix requires. Figure 1 is illustrative: the

*Equal contribution

†Corresponding author

¹Code: https://github.com/nreHieW/over-editing buggy function requires only a one-line boundary correction, and we verify that this single-line patch passes all five of the task's tests. GPT-5.4 instead deletes five lines and inserts 60, spanning input validation, dtype coercion, NaN masking, and curve resampling. The output passes the same five tests, so none of that additional code is required by the specification. Running the identical input through 20 frontier models indicates that this is a property of the model rather than of the task: among models whose five completions all pass the test cases, median patch size ranges from 2 to 60 inserted lines, and the most recent releases are not uniformly more conservative than the models they replace.

Existing coding benchmarks primarily measure functional success, through Pass@1 or Pass@k on tasks (Chen et al., 2021; Liu et al., 2023; Austin et al., 2021; Li et al., 2023; Zhuo et al., 2025; Jain et al., 2024). Repository-level and direct-editing benchmarks broaden the setting, but still mostly evaluate whether tests pass or issues are resolved (Jimenez et al., 2024; Chowdhury et al., 2024; Zheng et al., 2024a; He et al., 2025; Guo et al., 2025; Tian et al., 2024; Gauthier, 2024; Fu et al., 2025a). We aim to make edit fidelity measurable in its own right: not only whether a model fixes a bug, but whether it preserves the surrounding implementation when the required repair is local.

We construct a controlled evaluation framework from 400 BigCodeBench problems (Zhuo et al., 2025). For each reference solution, we inject one or two localized AST-level corruptions and retain the example only if the corrupted program fails the original tests. This gives each task a known minimal repair: the reversal of the injected corruptions. We evaluate model outputs with Pass@1 for functional success, normalized token-level Levenshtein distance for edit size, and added cognitive complexity for structural overhead. These metrics evaluate whether the model fixes a bug with minimal edits that are easier to understand and review. As the minimal repair is known by construction, the framework isolates over-editing as a failure: a model unnecessarily rewriting functional code on a localized repair task. Our scope is deliberately local code repair; open-ended generation, architectural refactoring, and feature extension, where broader rewrites are intentional, fall outside it.

Our results show that edit fidelity is a distinct axis of code-repair quality: (1) Over-editing is widespread: several frontier models, such as GPT-5.5, achieve competitive Pass@1 while still making unnecessarily large edits. (2) Prompting helps: a single preservation instruction reduces aggregate frontier excess Levenshtein distance from 0.195 to 0.131, lowers added cognitive complexity by 26.6%, and improves Pass@1 by 2.3 points. (3) Reasoning and scale are insufficient: reasoning effects are model-specific, and larger models do not monotonically produce smaller or simpler passing repairs. (4) Minimal editing can be learned: supervised fine-tuning overfits to seen corruption patterns, while reinforcement learning reaches 0.782 out-of-domain Pass@1 with 0.050 excess Levenshtein distance and does not degrade general coding ability. Qualitative analysis further suggests that over-editing is often a granularity mismatch: the model may identify the bug but rewrite data flow, add defensive checks, or change nearby behavior instead of making the local repair. Together, these findings show that over-editing is widespread, measurable, and reducible through prompting and post-training.

References (26)