AI Coding Agent Evaluation: From Code Generation to Reliable Bug Fixes
This article explains why evaluating AI coding agents requires more than measuring first-pass code generation. It covers the difference between building new features and maintaining existing systems, why additional debugging can sometimes reduce code quality, and how base model capability should be evaluated separately from agent engineering. It also outlines conservative repair practices, metrics for measuring benefit, risk, and cost, and a practical evaluation workflow for engineering teams.
1. Evaluating AI Coding Ability Is Not Only About the First Attempt
In real software development, coding tasks usually take two different forms. One is implementing a feature from scratch based on requirements. The other is locating and fixing defects in an existing system. Both require code understanding, but they place different demands on an AI agent.
Greenfield development is closer to an open-ended construction problem. As long as functional constraints are satisfied, the agent can usually choose the structure, organize modules, and arrange implementation steps relatively freely. Maintaining an existing system is a constrained modification problem. In addition to fixing the current fault, the agent must preserve existing behavior, remain compatible with existing interfaces, and avoid breaking business assumptions that may not yet be visible.
Therefore, the fact that an agent can generate a correct new feature does not mean it can safely maintain existing code. For engineering teams, the more important questions are not simply “Can it write code?” but:
- Can it accurately identify the location that should be modified?
- Can it understand the real cause behind an error?
- Will it break other functionality just to make the current test pass?
- Does it know when to pause and request confirmation if evidence is insufficient?
- Can it provide reviewable verification results after completing a fix?
The core phenomenon in the source material is that some approaches score lower after adding debugging steps, while others can improve results through multiple repair rounds. However, the material does not provide a complete experimental setup, task set, or statistical methodology. Therefore, the numbers alone cannot be used to derive a universal capability ranking.
A more valuable technical conclusion is: debugging does not naturally bring improvement. An agent’s modification strategy and verification mechanism directly affect final quality.
2. Why “Fix It Again” Can Make Code Worse
1. Local Feedback Is Mistaken for the Full Objective
Agents often decide the next modification based on error messages or failed tests. If an agent treats one failing case as the entire requirement, it may produce an overly specialized patch.
For example, if a certain input triggers an exception, the agent may directly add a special branch for that input. The current test may pass, but the underlying rule remains wrong, and other similar inputs may continue to fail.
This kind of fix addresses the surface problem of the test rather than the problem in the business rule. Reliable debugging must place the failing case back into the requirement context instead of mechanically modifying around a single case.
2. The Modification Scope Exceeds the Evidence Scope
In maintenance tasks, a common risk is turning a local defect into a broad refactor. An agent may simultaneously adjust data structures, rewrite call chains, change exception handling logic, and modify nearby code along the way.
These changes are not necessarily wrong, but they significantly increase the verification burden. Once a new problem appears, it becomes difficult to determine which change introduced the regression.
For repair tasks, a reasonable principle is: the modification scope should match the confirmed cause. Without sufficient evidence, the change should not be expanded to unrelated modules.
3. Incomplete Context Causes Implicit Constraints to Be Lost
Constraints in real projects are usually not limited to the current file. Interface compatibility requirements, historical data formats, caller assumptions, permission boundaries, and performance limits may be scattered across other modules or documentation.
If an agent only sees the failing function, it may generate a patch that is locally reasonable but globally incompatible. For example, changing a null value into an exception may seem intuitive for the current function, but it may break the caller’s existing fallback process.
This is also why code maintenance requires stronger context retrieval and dependency analysis than one-shot generation.
4. No Clear Stopping Condition
If an agent is asked to keep modifying code until all checks pass, without limits on attempts, budget, or risk, it may enter a low-value loop: fixing one problem while introducing another.
A reliable process should allow the agent to stop when evidence is insufficient, when the impact of a change is too large, or when repeated attempts produce no benefit. It should then output the current judgment, verified facts, and items that need confirmation. Stopping in time is an engineering capability, not a sign of failure.
3. Base Model Capability and Agent Engineering Capability Should Be Evaluated Separately
The base model is mainly responsible for understanding, reasoning, and generation. A coding agent, however, organizes file reading, code search, modification execution, test running, and result feedback around the model.
Therefore, final performance comes from the combined effect of multiple stages:
Task understanding → context retrieval → modification planning → patch generation → verification execution → feedback analysis → continue fixing or stop.
Even with the same base model, different workflows can produce different results. Conversely, a stronger model does not necessarily make the entire system more reliable.
It is especially important not to conclude that a system must use a specific safeguard just because it achieves a higher final score. Proving this requires inspecting execution traces or running controlled experiments that remove the relevant mechanism.
For enterprises, the selection target should not be only a model, but a complete engineering loop. At a minimum, the following capabilities should be observed:
- Can it locate relevant code instead of indiscriminately reading a large number of files?
- Does it clearly separate diagnosis, modification, and verification stages?
- Does it keep traceable records before and after each modification?
- Does it support recovery and rollback after test failures?
- Does it restrict sensitive operations and high-risk changes?
- Does it support human review of critical patches?
These mechanisms determine whether an agent can move from a demo scenario to long-term maintenance.
4. The Core of Reliable Repair: Conservative Changes, Not Passive Changes
A conservative strategy does not mean always changing only one line, nor does it mean refusing necessary structural adjustments. It means controlling the scope of changes under evidence support and prioritizing the reduction of uncertainty.
1. First Establish a Reproducible Failure Case
Before making changes, clarify how the fault is triggered, what the expected behavior is, and where the current behavior deviates.
For repeatable logic defects, automated regression tests should be created whenever possible. For issues that depend on concurrency, external services, or timing conditions, the runtime environment, key logs, and trigger conditions should be recorded.
If the problem cannot be reproduced stably, observation should be added first rather than immediately attempting a large-scale rewrite.
2. Define Behavior Invariants That Must Be Preserved
Before fixing, list the constraints that cannot be changed, such as:
- Input and output formats of public interfaces;
- Permission validation and sensitive data handling rules;
- Transaction boundaries and failure rollback behavior;
- Compatibility methods for historical data;
- Error handling semantics that have already been promised.
These constraints form the safety boundary of the patch. A successful fix means not only that the new test passes, but also that these invariants remain unbroken.
3. Use the Minimum Sufficient Change
“Minimum” means reducing unrelated changes. “Sufficient” means truly addressing the root cause. Both are required.
If the problem comes from boundary judgment, the boundary logic should be corrected first. If the problem comes from shared state design, adding only a special branch may not be enough to fix the root cause.
Therefore, whether a change is reasonable should not be judged simply by the number of code lines. Instead, each change should correspond to a clear problem cause or necessary constraint.
4. Verify in Layers Before Deciding Whether to Continue
A recommended approach is to expand verification scope step by step:
- Run tests that reproduce the original defect;
- Run related tests for affected modules;
- Check interface and data compatibility;
- Execute broader regression tests;
- Add human review for high-risk changes.
This process can detect obvious errors early while avoiding the need to run expensive full checks unconditionally after every modification.
5. Evaluating Agents Should Measure Benefit, Risk, and Cost Together
A single pass rate can hide important problems. For example, two agents may have similar final pass rates, but one may require many modifications and multiple retries, while the other needs only a few patches. Their maintenance costs are not the same.
At least the following groups of metrics should be established.
1. First-Round Quality
This measures whether the agent can complete the task without receiving feedback for further repair. It reflects requirement understanding and initial implementation ability, but it does not represent long-term maintenance capability.
2. Net Debugging Benefit
Under the same scoring standard, the following can be calculated:
Net debugging benefit = post-debugging score − first-round score.
A positive value indicates that debugging brought improvement. A negative value indicates that subsequent changes reduced overall quality. The distribution across different task types should also be shown to avoid averages hiding a small number of high-risk tasks.
3. Fix Rate and Regression Rate
Fix rate focuses on how many originally failing checks pass after modification. Regression rate focuses on how many originally passing checks fail after modification.
These two metrics need to be counted separately. Reporting only the number of fixes may make an approach that “fixed a few problems but broke more behaviors” still appear effective.
4. Change Scope and Review Burden
It is useful to record the number of modified files, interface changes, dependency adjustments, and human review time. Code lines can be auxiliary information, but they should not be directly equated with risk.
For enterprise maintenance tasks, review cost is often as important as model invocation cost.
5. Total Cost per Unit of Effective Output
Cost should include inference calls, tool execution, test resources, waiting time, human review, and failed rework.
A more expensive approach does not necessarily produce higher quality, and a cheaper approach does not necessarily have lower total cost. A reasonable comparison should be based on the same tasks and budget constraints, examining the total investment required to reach acceptable quality.
6. Automated Testing and Semantic Review Should Complement Each Other
Automated testing is suitable for verifying clear and executable behavior, but it can only cover assertions that have already been expressed. Passing tests does not mean all requirements have been implemented. Failing tests also require distinguishing real functional errors, environment issues, and outputs that do not conform to expectations.
Therefore, a complete evaluation can use a two-layer structure.
The first layer is deterministic checks, including automated tests, static checks, interface constraint validation, and necessary security checks.
The second layer is semantic review, checking whether the code satisfies the requirement description, whether anything is missing, whether the implementation bypasses logic to “please the tests,” and whether the implementation is maintainable.
Semantic review can be assisted by humans or review models, but model judges also have limitations:
- They may prefer answers that are more complete or longer;
- They may be misled by code comments or implementation explanations;
- They may interpret complex business constraints inconsistently;
- Giving the same score multiple times does not mean the judgment is necessarily correct.
Therefore, the review system should measure both the stability of repeated runs and the consistency with independent human judgment. These correspond to “whether it is reproducible” and “whether it is trustworthy,” and should not be confused.
Reviewers should also be required to point out specific evidence, such as missing requirements, violated constraints, and relevant code locations, rather than only outputting a total score. When permissions, data destruction, or other critical security requirements are involved, independent veto conditions should be set. These cannot be offset by scores from other features.
7. How Engineering Teams Can Build a Trustworthy Selection Process
1. Build a Layered Sample Set from Real Tasks
The task set should cover new feature development, boundary defect repair, interface compatibility, performance issues, and security-related changes. It should also distinguish low-risk tasks from high-risk tasks.
Do not select only small-scale tasks with clear requirements. Otherwise, the agent’s effectiveness in complex maintenance scenarios may be overestimated.
2. Keep Experimental Conditions Comparable
Different approaches should use the same code version, requirement description, execution environment, and time budget. If context permissions, tool permissions, or retry counts differ, they should be disclosed separately to avoid mistaking resource differences for capability differences.
It is also important to distinguish tests visible to the agent from held-out tests used only for final evaluation, reducing the risk of overfitting to known cases.
3. Keep Complete Execution Traces
In addition to the final code, record each round of modifications, test outputs, failure reasons, and stopping reasons. This makes it possible to determine whether the problem comes from model reasoning, missing context, tool execution, or the verification process.
Execution traces are also an important basis for later optimization.
4. Use Tiered Authorization
Low-risk, rollbackable changes can allow a higher degree of automation. Changes involving public interfaces, database structures, permission logic, and production configurations should retain human approval.
The degree of automation should match risk, not be determined by a single evaluation ranking.
8. Conclusion: Real Coding Ability Is Verifiable Continuous Delivery
Competition among AI coding agents should not be reduced to model price or one-time code generation scores. For real development, what matters more is whether the agent can improve steadily based on feedback, control modification boundaries, and prove that fixes do not break the existing system.
A trustworthy evaluation system should answer three questions: Is the first implementation correct? Do subsequent fixes produce net benefit? Is the whole process within acceptable risk and cost?
A reliable engineering process should do the following: reproduce the problem first, then confirm constraints; propose evidence-based changes first, then perform layered verification; roll back when necessary; and leave high-risk decisions to human review.
Only by examining generation capability, debugging strategy, and the verification loop together can engineering teams determine whether an agent is “writing more code” or “delivering more reliable software.”
