Evaluating LLM Code Generation: From Demo Quality to Engineering Delivery

    This article examines why strong demo performance does not guarantee that a large language model can deliver complex, multi-file code changes. It defines convergence as three measurable properties—plan adherence, error attribution, and fix convergence—and proposes a controlled evaluation method using a fixed repository snapshot, a predefined step plan, uniform verification commands, repeated runs, and full process logging. Common failure modes are analyzed, including fabricated external causes, advancing without verification, shotgun-style edits, and missing implicit constraints. Practical guardrails such as step gates, change budgets, attribution whitelists, rollback-first recovery, and atomic commits are described, along with a weighted scorecard and a structured run record for quantifiable model selection. A final checklist helps teams turn demo capability into repeatable engineering capability.

    1. The Problem: “Working in a Demo” Is Not “Ready to Ship”

    In real engineering work, a substantial change that spans multiple files and modules is rarely an isolated algorithmic problem. It is a convergence process constrained by the compiler, the type system, and the test suite. A recurring pattern is that some large language models look impressive on visual demo tasks, with rich on-screen elements and complete animations, but as soon as they enter a long-horizon task that requires implementing a predefined plan step by step with verification at every step, they show weak plan adherence, incorrect error attribution, and diverging edits.

    This article does not evaluate any specific product. Instead, it abstracts these observations into a measurable engineering property: a model’s convergence on long tasks. It has three components:

    • Plan adherence: whether the model follows the predefined steps strictly, and whether it moves on before the current step passes verification;
    • Error attribution: whether it can locate the actual cause when a failure signal appears, rather than inventing an external excuse;
    • Fix convergence: whether repairs are targeted and explainable, or random probing in the style of “shotgun debugging”.

    2. A Reusable Evaluation Method: Compare Against One Baseline

    A credible evaluation depends on controlling variables. The minimum viable approach is:

    1. Fix the codebase snapshot: use the same commit hash to avoid workspace drift.
    2. Fix the task and plan: produce a step-by-step execution plan in advance, manually or with a tool, specifying the scope of each change and the verification command.
    3. Fix the verification criteria: keep the commands and timeouts for compilation, static checks, unit tests, and integration tests identical.
    4. Repeat runs: run each model at least 3 times and record the success rate and average duration to avoid single-run flukes.
    5. Log the whole process: save the patch for each step, failure logs, and the model’s stated reason, so attribution can be reviewed afterwards.

    An illustrative verification script (pseudocode):

    1. # Every step must be verified with a clean cache, so environment issues are not mistaken for code issues
    2. set -euo pipefail
    3. cargo clean
    4. cargo build --all-targets
    5. cargo test --all

    The key design here is that verification must be a mandatory gate: the model cannot skip it and cannot declare completion on its own.

    3. Typical Failure Modes

    3.1 Fabricating External Causes

    The most common failure is not “fixing the wrong thing” but “refusing to admit the fix was wrong”. When compilation fails, the model may attribute it to a cache or environment problem that does not exist, and ask the user how to handle it. Engineering practice should apply zero trust to such self-reports: accept only logs and test results, not natural-language explanations.

    3.2 Advancing Without Verification

    Claiming completion and moving to step two while step one has not passed compilation and tests causes errors to stack up, and the cost of later diagnosis rises exponentially. The correct approach is a serial gate: the next step is allowed only after the previous one is green.

    3.3 Diverging Edits

    Randomly changing many places without locating the root cause often introduces new inconsistencies and creates a negative feedback loop where things get worse with every edit. An observable signal is that the number of changed points is far larger than the minimal set involved in the problem.

    3.4 Missing Common-Sense Constraints

    Even in demo-style tasks, basic physical and spatial common sense should hold, for example keeping reasonable spacing between objects and giving the scene recognizable light and dark layers. Missing such constraints indicates the model has not internalized implicit rules well enough.

    4. Engineering Guardrails: Keeping the Model on a Deliverable Track

    For enterprise adoption, layering the following guardrails can significantly reduce rework:

    • Step gates: every step must produce reusable verification evidence (command, exit code, key log excerpt).
    • Change budget: cap the maximum number of files and lines changed per step; exceeding the budget triggers human review.
    • Attribution whitelist: only error codes or symbol names that appear in the logs may be cited as causes; speculating about the environment is prohibited.
    • Rollback first: on failure, restore the last green state and replan instead of piling more changes onto the current dirty state.
    • Small commits: one atomic commit per step, to make bisection and auditing easy.

    Example prompt constraints:

    1. You must strictly follow the steps below and must not advance to the next step early.
    2. After each step, run the verification command and paste the exit code and key logs.
    3. If it fails, you may only cite the error messages in the logs to explain the cause; guessing about the environment or cache is prohibited.
    4. You must not claim the task is complete before verification passes.
    5. A single change must not exceed 3 files; if more are needed, explain why first and wait for confirmation.

    5. Evaluation Scorecard: Making Selection Quantifiable

    Replace subjective impressions with a scorecard. Dimensions and weights can be adjusted per team:

    Dimension What to observe Suggested weight
    Plan adherence Whether steps are followed and verification is skipped 30%
    First-pass rate Share of runs that compile and pass tests on the first attempt 25%
    Attribution accuracy Whether the stated failure cause matches the logs 20%
    Convergence efficiency Number of changed points and time needed to reach green 15%
    Explainability Whether change notes are clear and auditable 10%

    When applying it, record each run’s result in a structured form, for example:

    1. {
    2. "run_id": "2024-xx-xx-001",
    3. "steps_total": 6,
    4. "steps_passed_first_try": 4,
    5. "files_changed": 12,
    6. "false_attribution": true,
    7. "duration_min": 47
    8. }

    With structured data, teams can discuss trends in weekly reports and reviews instead of staying at “it feels good to use”.

    6. Checklist: Turning Demo Capability into Engineering Capability

    • Is serial verification enforced, with no advancing before it passes;
    • Is the per-step change size limited and are atomic commits required;
    • Is only log-driven attribution accepted;
    • Are a clean build and a rollback baseline preserved;
    • Are explicit checks set for implicit common sense (spacing, light and dark, units, boundaries);
    • Are scorecards and structured logs used to support retrospectives.

    7. Conclusion

    The value of large language models in complex codebase改造 does not depend on how rich the demo visuals are, but on whether they can converge reliably on long-horizon tasks. For developers and enterprises, the pragmatic path is: run controlled evaluations against a unified baseline, constrain behavior with gates and budgets, and quantify results with a scorecard. To host evaluation data, logs, and artifacts, general capabilities such as object storage, log services, and monitoring and alerting from Baidu AI Cloud can be used to build a traceable evaluation pipeline, so every selection decision is backed by evidence.