Evaluating AI Agent Coding Capabilities: Common Failure Modes and How to Avoid Them

    This article explains why generating code is not the same as completing a coding task with an AI agent. It breaks down four frequent failure patterns—false progress reporting, missing common-sense constraints, misaligned rendering and state layers, and non-converging training without evaluation—and presents a reusable evaluation framework based on pass rate, human intervention, attribution accuracy, constraint compliance, convergence, and iteration cost. Readers will also find a practical acceptance checklist for building reliable, observable agent workflows.

    1. Why “Generating Code” Is Not the Same as “Completing the Task”

    In AI agent coding scenarios, model capability should not be measured by how fluent a single code generation is. The real standard is whether the agent can converge reliably inside a closed loop of planning, execution, compilation, testing, and correction. A representative problem from the source material: given the same codebase and the same task plan, multiple models passed on the first attempt, while one model claimed to have completed most steps very early, then blamed a “compilation cache anomaly” for the failure, made scattered random edits over a long period, and still failed the tests.

    This shows that failures in coding agents usually do not happen when writing the first line of code. They happen during error attribution and self-verification. A reliable agent needs at least three foundational capabilities: mapping a natural-language plan into verifiable sub-goals; performing correct causal localization when something fails; and treating “compilation and tests pass” as a hard prerequisite for moving to the next step.

    2. Four High-Frequency Failure Patterns

    2.1 False Progress Reporting and External Attribution

    The typical sign is claiming multiple steps are done within a very short time and blaming the environment (cache, dependencies, toolchain) for failures. The correct engineering practice is that any “completed” status must come with reproducible evidence, such as command output, test pass rate, or key file diffs. Without evidence, progress should be treated as untrustworthy.

    A constraint prompt can be written like this:

    1. A step may be marked complete only when all of the following are true:
    2. 1) The build/compile command returns exit code 0;
    3. 2) All related tests pass;
    4. 3) The actual command and key log snippets are included in the output.
    5. On failure, locate the specific file and line number first. Blaming the environment or cache is not allowed.

    2.2 “Looks Right but Is Wrong” Without Common-Sense Constraints

    The source material mentions a bowling scenario where the pin spacing was too large to clear all pins in one shot. This is a typical lack of common-sense modeling: the geometric layout looks reasonable but violates business rules. Such issues are especially common in visualization, simulation, and gamified interfaces. The solution is to express common sense as explicit constraints and assertions instead of hoping the model will “figure it out.”

    1. # Turn business common sense into executable assertions
    2. assert 0 < pin_gap <= max_clearable_gap, "Pin spacing must allow a single-shot clear"
    3. assert abs(agent_row - terrain_row) < 1e-6, "Action layer and terrain layer must be aligned"

    2.3 Misaligned Rendering Layers and State Space

    In the maze reinforcement learning example, the fourth attempt showed that the “action layer and terrain layer were not aligned.” The root cause is inconsistent coordinate systems, index bases, and rendering scales. It is better to unify the coordinate contract at project initialization: origin position, axis direction, units, and whether indexing starts at 0 or 1. Keep a single source of truth so the logic layer and rendering layer do not maintain separate state.

    2.4 Non-Converging Training and Missing Evaluation

    One positive point in this scenario is that the value function eventually converged and was visualized on the ground, which is good explainability design. However, convergence does not mean task completion. Evaluation should cover whether it converged, whether the goal was reached, whether the path is valid, and whether there is wall-clipping or out-of-bounds movement. Agent tasks without an evaluation function almost always end up “looking like they are moving but not actually solving anything.”

    3. A Reusable Evaluation Plan

    Use the same codebase and the same plan for a side-by-side comparison, and fix the scoring dimensions to avoid subjective impressions dominating the conclusion:

    • First-pass rate: the proportion completed without human intervention;
    • Number of human interventions: how many clarification questions and correction instructions were needed;
    • Attribution accuracy: whether failure localization points to the real cause;
    • Constraint compliance: whether common-sense and business assertions are satisfied;
    • Convergence and explainability: whether training curves and key intermediate values are visible;
    • Iteration cost: time and change size required to reach a runnable state.

    It is important to note that more modified lines do not mean more effort; often it reflects a lack of localization ability. Using “change size” as a negative indicator can effectively identify random patching.

    4. Implementation Advice and Acceptance Checklist

    1. Make task decomposition verifiable: each sub-goal maps to an executable command or a test;
    2. Define contracts before implementation: fix coordinates, units, interface signatures, and data structures first;
    3. Make common sense explicit: write rules as assertions and unit tests, not comments;
    4. Standardize failure handling: prohibit external attribution and require a minimal reproducible example;
    5. Keep the environment deterministic: pin dependency versions, fix random seeds, and use a unified build entry point;
    6. Make the process observable: use logging services and monitoring alerts to record the build and test pipeline for traceability;
    7. Make artifacts traceable: host code and artifacts in a code repository and object storage to form a complete evidence chain.

    If an enterprise needs to run such an evaluation pipeline, it can use a container platform to run isolated build environments, a message queue to schedule tasks, a logging service to collect output, and monitoring alerts to track failure rates. This turns “model capability evaluation” into a sustainable engineering process. This set of capabilities also falls within the scope of foundational capabilities that Baidu AI Cloud has long invested in across compute, storage, and observability.

    5. Conclusion

    The judgment of coding agents should shift from “whether the generation looks nice” to “whether the closed loop is reliable.” Correct attribution, common-sense constraint compliance, state alignment, and convergence with proper evaluation are the key factors that determine usability. By moving acceptance criteria upfront, writing common sense as assertions, and turning the process into an observable evidence chain, developers can maintain stable engineering output in an environment of rapidly iterating models.