Repository-Level Bug-Fixing Evaluation: Methods and Practical Implementation
Learn how to evaluate an AI model’s ability to fix bugs across a code repository using executable tests, reproducible environments, and explicit budgets. This article covers task design, score interpretation, contamination controls, evaluation pipelines, failure analysis, and how to turn benchmark results into model selection and development decisions.
What the Evaluation Should Measure
Repository-level bug-fixing evaluation measures a model’s ability to locate defects from an issue description, modify implementations across multiple files, and pass both existing tests and new regression tests in a real or closely simulated code repository.
Unlike single-function completion or algorithm exercises, these tasks spread context across directories, build scripts, dependency declarations, and historical patches. Executable tests determine correctness—not a reviewer’s impression that a patch “looks right.”
For development teams, the value of these scores lies less in leaderboard positions than in answering three questions:
- Can the model make a minimal fix without breaking unrelated behavior?
- Is the repair process repeatable and auditable?
- Is a score change large enough to affect model selection or deployment decisions?
Open-weight models support local reproduction and private deployment. Closed-source services often retain an advantage on broader coding tasks, but that gap should be measured using the same tasks and execution environment. Scores from different periods or evaluation protocols should not simply be subtracted from one another.
How to Structure Evaluation Tasks
A suitable repository-level task should include, at minimum:
- A buildable code snapshot.
- A natural-language issue description.
- Failing tests or observable symptoms.
- Acceptance tests that remain hidden or are released later.
The issue description should explain symptoms and constraints, not walk the model through the patch. Otherwise, the task measures the ability to follow an answer rather than diagnose a defect.
Report results by difficulty category instead of relying only on an aggregate score:
- Single-file bugs with clear logic: Test basic localization and patch formatting.
- Cross-module interface inconsistencies: Test understanding of call chains, types, and contracts.
- Build, configuration, or data-migration bugs: Test understanding of environments and side effects.
- Bugs requiring additional regression tests: Test engineering completeness and prevention of recurrence.
Report both full-test pass rates and partial-pass results. A patch that fixes one assertion but introduces new failures can be more dangerous in production than no fix at all.
How to Interpret Score Differences
Adjacent leaderboard entries often differ by only fractions of a percentage point or one to two percentage points. With a limited task set and highly correlated failure modes, such differences may fall within sampling variability.
Results should therefore include:
- The number of tasks.
- The number of independent runs per task.
- Confidence intervals or bootstrap intervals.
- Whether multiple samples are allowed and the best result is selected.
A single-run point estimate does not justify describing a higher ranking as a stable leap in capability.
Aggregate scores also need to be broken down. Broad coding scores often combine completion, refactoring, test generation, and bug fixing. Near-frontier performance in one category does not imply comparable performance in long-context, multi-file editing.
If a gap narrows over six months, a more defensible interpretation is that training data, tool use, and inference-time search are improving. The remaining gap may be concentrated in a small number of difficult repositories rather than spread evenly across all tasks.
Before comparing open-weight and closed-source models, align the following conditions:
- Context window and truncation strategy.
- Access to repository retrieval.
- Permission to execute tests and revise patches over multiple rounds.
- Temperature and sample count.
- Timeouts and retries.
Relaxing any of these conditions can blur the distinction between model capability and search budget.
Contamination, Leakage, and Reproducibility
Once a public benchmark enters pretraining or post-training data, high scores may reflect memorized patches rather than reasoning.
Controls should include:
- Delayed publication of tasks and tests.
- Time-based repository splits that use only code from before a specified cutoff.
- Periodic replacement of issue descriptions with equivalent rewordings.
- Separate validation on private business repositories.
Private evaluation sets are unsuitable for public rankings, but they can serve as a final gate for model selection.
The execution environment must pin dependency versions, system libraries, and random seeds. Evaluation documentation should also specify build-cache and network-access policies. If the same patch produces different results in different images, classify the discrepancy as an environment issue rather than a model failure.
At minimum, retain the following logs and artifacts:
- A summary of the context shown to the model.
- The generated patch.
- Conflicts encountered when applying the patch.
- Test commands and exit codes.
Without these artifacts, scores cannot be independently checked.
A Practical Evaluation Pipeline
The following vendor-neutral workflow emphasizes evaluation stages rather than platform-specific interface names.
Object storage holds repository snapshots and logs, a container platform provides isolated builds, a message queue distributes tasks, and monitoring and alerts track timeouts and failure rates. If general-purpose container, object-storage, and logging services on Baidu AI Cloud are used for batch evaluation, image definitions, quotas, and data-retention policies should still be part of the evaluation specification. The choice of cloud account is not evidence of model capability.
for task in task_set:workspace = restore(snapshot(task))context = build_context(workspace, task.issue, budget)patch = model.propose(context) # Multiple rounds allowed; count them against the budgetresult = apply_and_test(workspace, patch, task.hidden_tests)record(task.id, patch, result, tokens, latency)aggregate(strict_pass, partial_pass, regression_rate)
Make the budget explicit: maximum context, maximum patch rounds, maximum test executions, and total elapsed time. Otherwise, repeated tool-assisted trial and error may overshadow the ability to understand a repository on the first attempt.
For enterprise model selection, report strict pass rate, the proportion of patches that introduce new failures, and per-task cost in compute time and model usage. Use a Pareto trade-off view rather than making decisions from a single aggregate score.
Failure Categories and Improvement Levers
Classifying failures is more useful than simply rerunning an aggregate benchmark.
- Localization failure: The model changes unrelated files or never reaches the module containing the root cause. Improve repository retrieval, symbol references, and call-chain summaries rather than merely lengthening the prompt.
- Unapplicable patch: Context lines or anchors are outdated. Require an applicable diff format, validate it programmatically, and reject patches that cannot be applied.
- Overfitting to visible tests: Public tests pass, but hidden tests fail. This suggests that the model is patching directly against failing assertions. Limit visible tests and penalize changes that merely delete assertions or weaken conditions.
- Behavioral regression: Target tests pass, but other suites fail. Treat regression rate as a hard gate rather than averaging it away in the overall score.
- Environment or dependency failure: The model changes a lockfile or image, but the project no longer builds. Report these tasks separately to avoid mixing them with logic-repair results.
Human spot checks remain necessary. Passing automated tests does not establish maintainability. Naming, exception paths, and security boundaries—such as expanded permissions or disabled validation—need checklist-based review.
Patches involving credentials, privilege escalation, or data deletion should not be merged automatically, even when tests pass.
From Evaluation to the Development Workflow
An evaluation set is a gate, not a substitute for everyday development.
A more reliable approach is to run a fixed subset against candidate models in continuous integration and run the full set periodically. Score improvements should be accompanied by improvements in the distribution of failure types, not just better results on easy tasks.
Before deployment, conduct shadow runs using internal issue tickets. The model proposes patches, maintainers decide whether to accept them, and the team records acceptance rates, rework rates, and production rollbacks. These operational metrics are better predictors of value than external leaderboard positions.
Prompts and tools should also be versioned. Changes to retrieval strategy, test visibility, or retry counts make historical scores non-comparable. Documentation should state the budget under which each conclusion holds, rather than presenting a high-budget search result as an intrinsic model capability.
Conclusion
Repository-level bug-fixing capability should be measured with executable tests, fixed environments, and disclosed budgets. Small score differences must be interpreted alongside uncertainty intervals and task composition. Open-weight models make reproduction easier, while any remaining advantage of closed-source models should be verified under the same protocol.
Evaluate pass rate, regression rate, and cost together. Feed failure analysis back into repository retrieval, patch validation, and code review. That is how evaluation becomes an engineering capability rather than a one-time leaderboard headline.
