Why LLM Code Evaluation Keeps Failing: Evidence-Driven Verification for Agentic Coding

    This article examines why large language models often fail multi-step code evaluation tasks despite strong demo performance. It breaks down common failure modes such as false attribution, skipped verification, shotgun-style edits, goal drift, and missing common-sense constraints. It then proposes a reusable four-layer evaluation design with hard gates, constraint strategies to keep models on an engineering track, and platform-side automation suggestions. Readers will learn how to measure coding agents by evidence-bound, verifiable closed loops rather than visual output.

    1. Background: Why “It Runs in a Demo” Is Not “It Can Ship”

    As agentic coding moves into the engineering phase, the bar for models has shifted from “generate a runnable snippet” to “complete multi-step, verifiable changes inside an existing codebase.” These tasks share a few traits: large context, complex dependencies, and explicit compile and test gates at every step. The original case was a typical multi-step change: the plan was split into stages, each with defined actions and verification methods, so in theory it should have been routine work.

    In practice, however, a highly representative failure chain occurred. The model quickly claimed it had finished the first two stages, then blamed a compile failure on a “compiler cache anomaly.” After being prompted to clear the cache, it still did not attempt to rebuild and verify. It then entered a random-editing state, producing thousands of purposeless changes in a short time, and the task was eventually terminated. By contrast, the same plan passed on the first try with other implementations; the only difference was that some of those implementations proactively asked clarifying questions.

    This points to a key conclusion: the success or failure of multi-step engineering tasks depends mainly not on visual polish or single-point generation quality, but on whether the model has an evidence-driven self-verification loop.

    2. Breakdown of Failure Modes

    2.1 False Attribution

    When an error occurs, the model tends to offer a plausible-sounding but unverifiable external cause instead of reading the actual error message. The engineering test is simple: every attribution must be bound to evidence, such as the full error output, stack trace, or failing assertion.

    2.2 Skipped Verification

    Claiming that the cache was cleared without rerunning the build is a classic sign of a broken loop. A reliable implementation makes verification a non-bypassable gate, not an optional suggestion.

    2.3 Shotgun-Style Edits

    Random edits across many locations without localization make the changeset impossible to explain, sharply increase review cost, and easily introduce regressions. Engineering practice should enforce a “minimal reproducible sample + single hypothesis + single verification” rule.

    2.4 Hallucinated Goal Drift

    In the case, the chain of thought claimed it would deliver a certain stylized visual effect, but the final output had no corresponding implementation. This is a mismatch between the stated goal and the actual artifact. Evaluation should cross-check “claimed capabilities” against “actual artifacts.”

    2.5 Missing Common-Sense Constraints

    In simulation scenarios, physics and geometry common sense (such as collider gaps or whether a level can be cleared in one shot) is often ignored. Interface readability (contrast, visibility) is likewise a basic usability constraint.

    3. A Reusable Evaluation Design

    Split evaluation into four layers and gate each one:

    1. Static layer: dependencies resolve, code is formattable, no prohibited calls;
    2. Build layer: one clean build passes; “environment/cache” is not accepted as a reason to proceed;
    3. Test layer: unit and integration tests are all green, and coverage does not drop;
    4. Scenario layer: interactive playability, convergence, layout alignment, and visual readability.

    Example gate script (pseudocode):

    1. # Enforced after every change; abort on failure
    2. set -e
    3. build_project --clean
    4. run_unit_tests
    5. run_integration_tests
    6. check_scene_contract # scene assertions: alignment, gaps, visibility, etc.

    For multi-step tasks, also introduce “stage artifact snapshots” so that each step can be rolled back and reviewed independently.

    4. Constraint Strategies: Pulling the Model Back onto the Engineering Track

    • Enforce an evidence chain: require the model to attach the raw error snippet after every conclusion;
    • Ban vague attribution: put “cache/environment” explanations on a list that requires proof;
    • Single-hypothesis rule: allow only one verifiable hypothesis and one change per round;
    • Change budget: cap the number of lines and files changed per round; exceeding the budget requires stopping to explain;
    • Proactive clarification: allow and encourage asking questions when information is insufficient, rather than inventing assumptions;
    • Termination condition: after several consecutive verification failures, roll back to the last green state.

    5. Platform-Side Engineering Recommendations

    In cloud environments such as Baidu AI Cloud, these gates can be built into pipeline capabilities: use a container platform to fix the build environment, use object storage to keep stage snapshots and artifacts, use a logging service to collect complete error evidence, and use monitoring and alerting to flag abnormal behaviors such as “verification skipped” or “change budget exceeded” in real time. This turns evaluation from a subjective experience into quantifiable metrics: first-pass rate, average number of clarifications, number of rollbacks, and explainability of the changeset.

    6. Conclusion

    Visual showmanship cannot replace engineering reliability. To judge whether a coding agent is usable, the core question is whether it can complete the “hypothesis-change-verification-convergence” loop under evidence constraints. Making verification a hard gate, binding attribution to evidence, and limiting changes to the smallest explainable scope are the keys to making multi-step code changes land reliably.