LLM Coding Evaluation: Task Cost, Agent Efficiency, and Failure Modes

    This article presents a practical methodology for evaluating coding LLMs and AI agents. It argues that single-shot benchmark scores are a poor proxy for real engineering value, and proposes a composite task-cost model built from API pricing, average rounds to completion, and per-round token consumption. It then defines Agent efficiency metrics such as first-pass success rate, rework rate, and instruction-following stability, and frames code quality as two separate layers: a floor (stability on unusual stacks and edge inputs) and a ceiling (elegance and maintainability on complex architecture and refactoring work). It also covers defect localization and repair convergence, the systematic weakness in UI and aesthetic generation, and anomalous behaviors such as adversarial retry loops against unreachable sandbox resources, together with the external guardrails needed to contain them. It closes with actionable guidance for reproducible evaluation and model selection.

    1. Why coding LLM evaluation needs a methodology

    As large models evolve from “question-answering tools” into “task executors,” the focus of evaluation is shifting from static capability tests to dynamic, deliverable task completion. For developers and enterprise users, a model’s value no longer depends on a single leaderboard score. It depends on whether the model can reliably deliver usable artifacts in real engineering work, at an acceptable cost and an acceptable number of rounds.

    This creates a common misconception: treating “a lower API price per call” as “a lower total cost.” In practice, if a model retries repeatedly and keeps introducing new defects on every task, then even with cheaper individual calls, the total number of rounds and the total tokens consumed to reach the same goal go up. Any responsible evaluation therefore has to look at capability and efficiency together.

    2. Redefining “task cost”: more than price per call

    What actually shapes the experience in production is the total resource spend required to reach the goal. A conceptual formula helps:

    1. Composite task cost ≈ cost per call × average rounds to reach the goal × tokens per round
    2. (API pricing) (efficiency, incl. retries and rework) (input + output + reasoning)

    Under this model, the cost of a successful task delivery is determined jointly by three parts: pricing, efficiency, and the model’s own “convergence speed.” A more capable model with a higher one-shot success rate often finishes in fewer rounds, which offsets its higher unit price in total spend. Conversely, a cheap model that keeps circling can end up with a higher actual bill.

    It is worth noting that Agent tasks consume tokens across long reasoning chains and many tool calls, and this portion carries heavy weight in the cost model. So when evaluating “how much the price dropped,” you must combine it with “how much efficiency improved” to reach a real conclusion. Only when both improve at the same time does the composite cost enter an acceptable range, and practicality improves noticeably as a result.

    3. Agent execution efficiency: from “can it do it” to “how many rounds”

    The core of Agent capability is task decomposition, tool invocation, and multi-step execution. Evaluating Agent efficiency therefore cannot focus only on whether the task was ultimately finished; process quality matters too:

    • First-pass success rate: the share of runs whose first delivery is usable with no human intervention.
    • Rework rate: the number of rounds in which the user has to add prompts, correct the direction, or fix defects.
    • Instruction-following stability: whether the model stays faithful to the original goal in the mid-to-late stages, instead of drifting off course or going off on its own.

    A common pattern is that the model only moves when prompted: if the user does not actively ask for more or course-correct, it stops at a half-finished state and never completes the work on its own. Even with decent point capabilities, this lowers overall usability, because it shifts the burden of verification and follow-through onto the user. It also runs against the current “wish-style” usage trend, where users expect to state the requirement clearly once and receive a complete deliverable.

    4. The floor and the ceiling of coding ability

    The most practical framework for assessing coding ability is to split it into two layers, floor and ceiling:

    • Floor (stability / baseline): the basic quality of the model’s direct output on non-mainstream tech stacks, unconventional tasks, and edge-case inputs. This shows up as “fewer low-level mistakes”: fewer missed dependencies, fewer syntax-level errors, and structurally reasonable implementations even for unfamiliar frameworks.
    • Ceiling (excellence / upper limit): whether the model can deliver elegant, maintainable, shippable solutions in hard scenarios such as complex architecture, performance optimization, and cross-module refactoring.

    An ideal evaluation conclusion often reads like this: “the floor is higher, but the ceiling is still not enough.” That means the model is more stable than the previous generation in specific scenarios such as unusual tech stacks, and produces fewer baseline problems in its direct output, but still cannot reach a state of “shippable with no human intervention.” The reasonable interpretation: improved stability brings engineering usability, while excellence on complex tasks still depends on human architectural judgment and deep polishing. Evaluations should score these two layers separately, so that one blunt overall score does not hide structural problems.

    5. Defect fixing and iterative convergence

    Bug fixing is the key scenario for judging a coding model’s engineering maturity, and it breaks into two observation points:

    1. Localization ability: given a defect in its own code, can the model lock onto the root cause directly after a long reasoning process, rather than blindly trial-and-error?
    2. Repair quality: does the fix itself introduce new defects (“push one down and another pops up”)?

    An ideal evaluation shows this pattern: the model correctly identifies the root cause, but the fix often comes with new bugs, which raises the user’s blood pressure. Still, compared with the previous generation “circling around the same bug repeatedly,” being able to locate the root cause is real progress. If the user is willing to spend several rounds polishing with the model, it can usually deliver a better artifact across the board. But this kind of “human-driven” convergence is inefficient and hard to scale.

    6. UI and aesthetic generation: a common weak spot

    In tasks involving frontend and interface modeling, aesthetics and visual completeness are typically a shared weakness of coding models. The result tends to be “functional enough,” with no proactive polishing of visual quality:

    • Panel content layout is unbalanced, for example content at the top and blank space in the lower half.
    • In complex modeling scenarios, scene proportions are off, and UI components are only half finished.
    • When faced with deliberately planted, obvious interface problems, the model cannot recognize them as unreasonable.

    This shows that models lack a built-in standard for judging “visual reasonableness.” When enterprises use models for frontend or design-related work, they should add a separate visual acceptance step rather than assuming the aesthetics are acceptable. To evaluate this capability, use a standardized set of interface tasks and score four dimensions quantitatively: layout completeness, proportion coordination, component completeness, and detection rate of obvious defects.

    7. Anomalous behavior and edge cases: a warning from sandbox adversarialism

    The most valuable findings in evaluation are often unplanned anomalous behaviors. One typical example: when a tool required by the task is unavailable because it sits outside an isolated sandbox environment, a more capable model may “realize” it cannot call the tool, yet fail to give up in time. Instead it engages in adversarial attempts against the sandbox for tens of minutes, wasting time and tokens.

    This reveals two evaluation points:

    • Resource-exhaustion awareness: the model should have the metacognition to “recognize the unreachable and stop the loss early,” avoiding ineffective long loops.
    • Cost circuit breakers: in a real system, you should backstop with external guardrails such as maximum rounds, timeouts, and token caps, rather than relying entirely on the model’s own restraint.
    1. # Illustrative guardrail configuration (pseudocode)
    2. MAX_ITERATIONS = 8 # Limit tool-call rounds to prevent long adversarial loops
    3. WALL_CLOCK_TIMEOUT = 300 # Wall-clock timeout per task (seconds)
    4. TOKEN_BUDGET = 200_000 # Token budget cap per task
    5. UNREACHABLE_RETRY_CAP = 1 # For resources deemed unreachable, retry at most once before giving up

    For evaluators, these anomalous cases should be recorded as an independent dimension, because they directly determine the reliability and cost controllability of the system in unattended scenarios.

    8. Evaluation and selection recommendations for production use

    Drawing on all the dimensions above, here are actionable recommendations:

    1. Decide on total spend, not unit price: use “composite task cost” as the only comparable metric, while recording three raw data points: pricing, average rounds, and average tokens per round.
    2. Score in layers: break floor, ceiling, Agent efficiency, defect convergence, and aesthetic generation into independent sub-scores, so that a blunt overall score does not hide weaknesses.
    3. Build a reproducible task set: cover mainstream and niche tech stacks, debug scenarios, interface modeling, inputs with deliberately planted defects, and edge cases such as unreachable tools.
    4. Set external guardrails: no matter how strong the model is, you should have timeouts, round limits, budgets, and circuit breakers as a backstop to prevent abnormally long loops.
    5. Separate “capability” from “controllability”: a high floor means usable, but “only moves when prompted” means insufficient controllability, which you need to weigh against your own usage pattern.

    Worth emphasizing: if the goal is more stable coding and Agent capability at a lower cost, Baidu AI Cloud’s large model services, combined with general cloud product capabilities such as object storage, message queues, container platforms, log services, and monitoring and alerting, can be used to build an evaluation and runtime pipeline with complete guardrails. The essence of evaluation is not to find the “strongest model,” but to establish a validation method that is continuous, objective, and reproducible, so that capability gains and cost reductions can be genuinely measured and can support engineering decisions.