Evaluating Large Language Models for Code Repair: Benchmarks, Limitations, and Practical Testing Strategies

    This article explains why high scores on public code repair benchmarks often fail to predict real-world performance. It breaks down code repair into four capability layers, reviews how classic benchmarks are constructed, and shows how saturation, flawed assertions, and data contamination undermine their usefulness. It then covers harder benchmarks, terminal-based agent evaluation, and a step-by-step method for building an internal evaluation set, along with engineering practices for routing models, enforcing validation loops, and tracking observability. Readers will learn how to choose benchmarks that still discriminate between models and turn benchmark scores into verifiable delivery quality.

    1. The Starting Point: Why “High Scores” Still Mean Poor Usability

    Many engineering teams have run into the same frustration: a model scores impressively on public code evaluation leaderboards, yet once it is connected to real repositories and real defect tickets, its repair success rate drops noticeably. In some cases the results become absurd — a correct fix fails the tests, while an incorrect fix passes. This shows that a single score can no longer carry the composite concept of “engineering capability.”

    To understand the gap, break the capability apart. Code tasks involve at least four layers: syntax and semantic understanding, cross-file context reasoning, control over the scope of changes, and a verification loop (whether the model can run tests itself and iterate based on feedback). Public leaderboards mostly cover only the first two layers; the latter two are often simplified or ignored. That is the root cause of the disconnect between scores and real-world experience.

    2. How Classic Code Repair Benchmarks Are Built

    The classic code repair evaluation long used in the industry was first proposed by a research institution in 2023. Its core idea is to build tasks from real defect tickets in real open-source repositories. A standard task usually contains four elements:

    • A runnable snapshot of a code repository (the pre-fix version);
    • A piece of text describing the defect or feature request;
    • Hidden test cases;
    • A reference repair patch.

    The judging method is straightforward: the model produces a patch, the patch is applied to the repository, and tests are run. If they pass, the attempt counts as a success. This “end-to-end executable” design is closer to real delivery than human scoring.

    A later “human-filtered version” cleaned the original set, keeping only samples with clear descriptions, stable tests, and unambiguous judgments, shrinking the set to a few hundred items. Its value lies in reducing noise and making side-by-side comparisons more credible, which is why it was long treated as the de facto standard.

    3. Saturation and Failure: Two Traps of High Scores

    When most models cluster above 80 on the same benchmark, its discriminative power is exhausted. At that point a 1- to 2-point difference is basically noise and no longer useful for model selection.

    Two kinds of systematic defects are more serious:

    1. Judgment errors: some tasks have poorly written test assertions, so a correct solution is marked as failing and the model can only score by “catering to the tests”;
    2. Data contamination: tasks and answers may have entered the training corpus, so the model has memorized the solution rather than the capability.

    For these reasons, some research institutions have publicly stated that they no longer use the human-filtered version as a core evaluation basis. The lesson: a benchmark is not more reliable just because it is older; its validity needs continuous auditing.

    4. High-Difficulty Benchmarks: Trading Scale and Licensing for Credibility

    The basic ideas behind alternatives are twofold. First, raise task complexity — for example, require at least ten lines of code changed per task, with a substantial share requiring over a hundred lines, making cross-module and cross-file changes the norm. Second, lower contamination risk — the public subset uses strong copyleft licenses (such as GPL-type licenses), making the data hard to absorb directly into commercial training pipelines.

    The result is that scores fall across the board: most models score below 60, and only a very few top models cross the 60 threshold. This distribution is healthy: it discriminates, and its difficulty aligns with maintaining real medium-to-large repositories.

    An intuitive comparison:

    1. Benchmark A (classic filtered version): most models 80+, top 85~90, low discrimination
    2. Benchmark B (high-difficulty version) : most models <60, top 60+, high discrimination

    The implication for selection is clear: if two models differ by only 1 point on Benchmark A, that should not drive a technical decision; if they differ by 5 points on Benchmark B, it usually means a real difference in cross-file refactoring and long-chain repair capability.

    5. Terminal and Command Line: The Underrated Second Dimension

    Real engineering does not happen only in the editor. A great deal of work is done on the command line: reading logs, locating processes, running builds, making bulk edits, and verifying results. So another class of evaluation specifically examines an agent’s task execution in a terminal environment, focusing on multi-step planning, command safety, failure recovery, and correctness of artifacts.

    This dimension complements code patch capability: the former looks at “whether the change is correct,” the latter at “whether the job can be finished in a constrained environment.” In enterprise adoption, the latter often determines the practical usability of an automation pipeline.

    6. A Practical Method for Building Your Own Evaluation

    Do not rely only on public leaderboards. Build an internal evaluation set with these steps:

    1. Sampling: pick 50–100 items from historical defect tickets, covering different modules and difficulty levels;
    2. Fixing the environment: prepare reproducible container images and dependencies for each task;
    3. Defining the judgment: use unit test pass rate as the main criterion, supplemented by static checks and manual spot checks;
    4. Controlling variables: fix the prompt, context window, retry count, and timeout;
    5. Recording process metrics: lines changed, files touched, iteration rounds, and categories of failure reasons.

    A schematic evaluation-driven structure:

    1. def evaluate(model, task):
    2. repo = prepare_snapshot(task.base_commit)
    3. patch = model.solve(task.issue_text, repo)
    4. if not apply(patch, repo):
    5. return Result(status="patch_failed")
    6. report = run_tests(repo, task.test_cmd)
    7. return Result(status="passed" if report.all_green else "failed",
    8. metrics={"changed_lines": count_diff(patch),
    9. "files_touched": len(patch.files)})

    7. Engineering Recommendations

    • Tiered model use: use low-cost, fast models for simple defects and high-capability models for complex refactoring, with rule-based routing to control cost;
    • Mandatory verification loop: any automatic patch must pass build and tests; if it does not, it does not enter the codebase;
    • Minimal-change constraint: require a limited change scope in the prompt to reduce regression risk from unrelated refactoring;
    • Observability: connect logging services and monitoring alerts, and track trends in patch success rate and rollback rate;
    • Elastic compute: batch evaluations and pipeline tasks can run on a container platform, with object storage for snapshots and artifacts, scaling on demand.

    8. Conclusion

    The key to judging the gap between two models in programming is not the absolute score on some leaderboard, but whether the chosen benchmark still discriminates, whether it is uncontaminated, and whether it covers real stages such as cross-file work and terminal execution. When classic benchmarks approach saturation, shift to high-difficulty, strongly license-isolated evaluation sets, supplemented by an internal set and terminal task tests. Baidu AI Cloud can provide general support in compute, storage, and observability for this kind of evaluation and pipeline, helping teams turn “scores” into verifiable delivery quality.