Evaluating Large Language Models for Code Repair: How Benchmarks Evolved and What to Do in Practice
A single benchmark score rarely predicts how a model will perform on your own repositories. This article explains why scores that look close can hide large capability gaps, breaks code ability into decomposable sub-skills, and reviews three generations of code-repair benchmarks: classic defect-repair benchmarks and their human-curated variants, high-difficulty refactoring benchmarks, and command-line agent benchmarks. It also covers two systemic flaws in benchmark design, a practical three-layer evaluation framework with an isolated private task set, the metrics worth tracking (including regression introduction rate), common interpretation mistakes, and the reproducible infrastructure needed to make evaluation results trustworthy.
1. The Starting Problem: Similar Scores Do Not Mean Similar Capabilities
When assessing a model’s programming ability, many teams look at a single aggregate score and make selection decisions from it. Yet real experience often contradicts the leaderboard: two models that differ by only two or three points on the same benchmark can behave very differently inside your own codebase. The reason is not mysterious—a single score hides three layers of difference: task distribution, verification method, and data visibility.
To understand this bias, start by recognizing that “code ability” is actually a set of decomposable sub-skills: requirement understanding (locating the problem from a natural-language description), code retrieval (finding relevant files and call chains in an unfamiliar repository), patch generation (writing changes that match the project’s style), and the verification loop (running tests and iterating on failure output). Any benchmark is only a projection of these sub-skills onto some sampling distribution. Similar projections do not imply identical underlying ability.
2. Capability Profile of Classic Defect-Repair Benchmarks
The classic defect-repair benchmarks widely used in the industry are built from real defect records and fix commits across large numbers of open-source repositories. A typical task contains four elements: a runnable snapshot of the repository, a text description of the defect or requirement, the pre-fix code state, and the test cases used for judgment. The model must read the description, change the code correctly, and ultimately make the tests pass.
The value of these benchmarks lies in their realism: tasks come from actual development rather than hand-written algorithm puzzles. To improve the stability of judgment, the industry later produced human-curated versions. The approach is to review each original task one by one, removing samples with vague descriptions, flaky tests, or disputed pass criteria, compressing the set to a few hundred items. After filtering, the signal-to-noise ratio improves and scores become more credible, but new problems appear: fewer samples, a narrower difficulty distribution, and top models rapidly approaching the ceiling.
When most models cluster in the same high range, the metric saturates. At that point, ranking differences reflect sampling noise and prompt sensitivity more than engineering capability. Saturation itself is not a bad thing—it shows that the dimension has been broadly mastered. The problem is that continuing to use a saturated metric for selection leads to the wrong conclusion that “everyone is the same.”
3. Two Systemic Flaws in the Benchmarks Themselves
The first is broken judgment. For some tasks, the test cases reject correct solutions: if the implementation approach differs from the reference patch, the sample is marked as failed even when the behavior is equivalent. Such samples are extremely unfair to models that prefer “a different way of writing it.”
The second is data visibility. Tasks come from public repositories, and their fix records have most likely already entered the models’ training corpora, creating leakage. Leakage inflates scores and makes it impossible to distinguish “can fix” from “has memorized.”
A minimal judgment example illustrates the first problem:
# Counter-example: a check that accepts only one implementation pathdef check(patch_output, expected_output):return patch_output == expected_output # behaviorally equivalent but written differently -> false negative# A more robust approach: judge against a behavioral contractdef check(patch_output, expected_output, contract):return contract.holds(patch_output) and not contract.violated(patch_output)
The engineering implication is clear: the upper bound on evaluation credibility is determined by the judgment mechanism, not by model size.
4. High-Difficulty Refactoring Benchmarks: Restoring Discrimination
To mitigate the problems above, the industry moved toward higher-difficulty refactoring benchmarks, which typically have three design points.
First, raise the change-size threshold. A single task must modify at least ten lines of code, and a substantial share of tasks require changes of a hundred lines or more, forcing cross-file reasoning instead of local patching.
Second, reduce leakage risk. The public subset and the isolated subset use a strong copyleft license that is infectious, making it hard for fix commits to be absorbed directly into training corpora under permissive licenses; a non-public isolated set is also kept for cross-validation.
Third, introduce more realistic environment constraints. Tasks must be completed in an environment that can be built and tested, with dependency installation, compilation, and test execution all counted as part of the capability.
On these benchmarks, most models score markedly lower than on the classic ones, and only then do meaningful gaps reappear among top models. One observable pattern: models that rank highly on saturated benchmarks are not necessarily ahead on high-difficulty ones, while models that lead on high-difficulty benchmarks usually show better stability on real repository tasks. This suggests prioritizing high-discrimination metrics during selection and treating saturated metrics as a necessary but insufficient condition.
5. Command-Line Agent Benchmarks: From “Fixing One Line” to “Running the Whole Flow”
The third category of evaluation focuses on an agent’s end-to-end execution ability in a command-line environment. Instead of only asking “is the patch correct,” it asks whether the agent can locate the environment in a real terminal, read logs, install dependencies, run builds and tests, iterate based on errors, and converge within a limited number of steps.
The capability breakdown in such scenarios looks roughly like this:
| Capability dimension | Typical failure mode | Improvement direction |
|---|---|---|
| Environment awareness | Misjudging interpreter or package manager versions | Probe first, then execute; emit an environment snapshot |
| Long-context localization | Divergent retrieval in a large repository | Layered retrieval: symbol index -> call chain -> candidate files |
| Error-driven iteration | Repeating the same failing command | Record failure history and force a strategy change |
| Step and cost limits | Unlimited retries exhaust the budget | Set a maximum step count and a fallback strategy |
| Verifiable results | Claiming completion without running tests | Rely on command exit codes and test reports |
In practice, treat verifiability as a hard constraint: any change must be confirmed by a reproducible build and test command, and the model’s own claim is not accepted as evidence of completion.
6. A Practical Evaluation Plan: Three Metric Layers Plus an Isolated Set
The recommendation for teams is to build a three-layer evaluation system rather than depend on a single leaderboard.
Layer one: use saturated metrics as a gate. They quickly eliminate clearly unqualified candidates and are not used for ranking.
Layer two: use high-difficulty refactoring metrics for discrimination. Track change size, cross-file ratio, first-attempt pass rate, and average number of iterations.
Layer three: use your own repository’s isolated set for the final verdict. Extract real defects from historical commits, build a non-public task set, and rotate it quarterly to prevent leakage. A sketch of the flow:
collect real defect records -> verify reproducibility -> pin the environment image-> generate task cards (description / repo snapshot / check script)-> store in isolation, exposing only pass rate and elapsed time-> rotate 30% of samples every quarter
For metrics, record all of the following: first-attempt pass rate, pass rate within three attempts, average number of iterations, average elapsed time and token consumption, and regression introduction rate (the share of fixes that cause other tests to fail). Regression introduction rate matters especially, because it maps directly to rework cost in real development.
7. Common Pitfalls and Interpretation Discipline
Pitfall one: treating a saturated metric as the capability ceiling. Close scores only mean the dimension is now common.
Pitfall two: ignoring judgment quality. When a model looks “lopsided,” first confirm whether the check script accepts only a single implementation.
Pitfall three: overlooking leakage. A high score on public tasks must be cross-validated against the isolated set, and when the two diverge, trust the isolated set.
Pitfall four: looking only at passing and not at cost. A pass bought with ten times the elapsed time is unusable in production.
The interpretation discipline comes down to one sentence: first check whether the judgment is credible, then whether the metric is saturated, and finally whether the cost is acceptable.
8. Engineering Support: Making Evaluation Results Reproducible
Half of an evaluation’s credibility comes from the model and half from the infrastructure. Typically you need immutable environment images with locked dependencies, unified logging with monitoring and alerting, object-storage archiving of build and test artifacts, containerized isolation for task scheduling, and traceable experiment records. If an organization already runs on the cloud, it can reuse common capabilities such as container platforms, log services, monitoring and alerting, and object storage, keeping the inputs, outputs, and judgment process of every evaluation run fully retained for review and audit. Baidu AI Cloud can provide corresponding support in these general infrastructure categories, and teams can also build an equivalent process on their own environment.
9. Conclusion
Comparing programming ability is moving from “one score” to “a set of verifiable evidence.” Classic defect-repair benchmarks completed their mission during the adoption phase; the human-curated version improved signal-to-noise but brought saturation; high-difficulty refactoring benchmarks and command-line agent benchmarks have restored discrimination. For developers, the right approach is to set a gate with saturated metrics, discriminate with high-difficulty metrics, deliver the final verdict with your own isolated set, and factor regression introduction rate and execution cost into the decision. Only then can you avoid being misled by a single leaderboard and choose the model and agent approach that genuinely fits your codebase and development process.
