How to Benchmark AI Coding Agents: Unit Cost per Success and Success Rate

    This article explains how to benchmark AI coding agents by measuring both task success rate and the average cost per successfully completed task. It covers the components of an agent runtime framework, how to build a sound evaluation metric system, key principles for designing reproducible experiments, a worked example of cost aggregation, practical rollout recommendations, and common pitfalls to avoid when comparing frameworks. Readers will learn how to produce repeatable, decision-ready evaluation results instead of relying on demos or public leaderboards.

    1. Why Benchmarking Agents Matters

    AI coding agents have evolved from simple code completion into autonomous systems that can read codebases, call tools, execute commands, and modify files. The same underlying model paired with different runtime frameworks can perform very differently on real tasks. As a result, teams need a repeatable evaluation methodology for framework selection, rather than relying on one-off demos or public rankings.

    Public leaderboards are useful references, but they have three inherent limitations. First, their task distribution may not match your team’s actual workloads. Second, model versions, parameter settings, and runtime environments are often opaque. Third, a single run is affected by randomness, so rankings fluctuate easily.

    2. Define What You Are Evaluating: The Components of an Agent Runtime Framework

    A runtime framework is the software layer that wraps the large model and turns model output into real operations. What you are comparing in an evaluation is the combined “model plus framework” stack, not the model alone. A typical runtime framework includes the following modules:

    • Model invocation layer: handles request formatting, timeouts, retries, and rate limiting.
    • Context management: decides which code, documents, and conversation history go into the prompt. This directly affects token consumption and edit accuracy.
    • Tool invocation layer: exposes capabilities such as file read/write, command execution, and code search to the model in a structured way.
    • Task orchestration: breaks tasks down, plans steps, and decides when to stop.
    • Permissions and sandboxing: restricts which commands can run and which paths are accessible, forming the security boundary.
    • Logging and replay: records every step so teams can review failure causes and attribute costs.

    Understanding these modules explains why two frameworks produce noticeably different scores on the same model. The differences usually come from context strategy, step planning, and failure recovery — not from the model’s inherent capability.

    3. Building the Metric System

    3.1 Task Success Rate

    Success rate is the most basic metric, but it is only meaningful when the pass criteria are clearly defined. Common criteria include: all relevant test cases pass, static checks report no new errors, and changes stay within the specified files. The criteria must be written down before the evaluation starts. Adjusting them afterwards makes results impossible to compare across frameworks.

    3.2 Unit Cost per Success

    Cost should be measured as the average spend per successfully completed task, not the price of a single call. The formula is:

    Unit cost per success = Total spend / Number of successful tasks

    Total spend must include the full cost of failed tasks. If a framework is cheap per call but has a high failure rate, its unit cost per success may actually exceed that of a framework with a higher per-call price but a more stable success rate. Looking only at per-call pricing leads to the opposite conclusion.

    3.3 Latency and Stability

    Latency can be split into time to first response and end-to-end completion time. Stability can be measured by the variance in success rate across multiple runs of the same task. A framework with high variance requires more human fallback in production, and that hidden cost should factor into the selection decision.

    3.4 Cost Breakdown

    Costs mainly come from input tokens, output tokens, cache hit rates, and additional requests caused by retries and multi-round tool calls. These items should be tracked separately. If you only look at the total, you cannot tell whether optimization should start with context trimming or with reducing retries.

    4. Key Principles of Evaluation Design

    1. Fix the variables. Keep model version, sampling temperature, maximum steps, and timeout identical; vary only the framework being compared.
    2. Use a representative task set. Tasks should cover real-world types such as bug fixing, feature implementation, refactoring, and test writing, across codebases of different sizes.
    3. Run multiple times. Run each task several times and report the mean and distribution, so a lucky success is not mistaken for a stable capability.
    4. Set budget caps. Define a spend or step limit per task; exceeding it counts as a failure, preventing runaway resource consumption on individual tasks.
    5. Sample manually. Beyond automated checks, spot-check a portion of “successful” results to confirm the change quality actually meets the bar, ruling out cases that pass tests but are poorly designed.

    5. Example of Cost Aggregation

    The pseudocode below shows how to compute the unit cost per success from run logs.

    1. total_cost = 0
    2. success_count = 0
    3. for run in run_logs:
    4. total_cost += run.input_tokens * price_in + run.output_tokens * price_out
    5. if run.passed_all_checks:
    6. success_count += 1
    7. unit_cost = total_cost / success_count

    The price_in and price_out values should come from the same pricing table at the same point in time. If different frameworks are compared using prices from different dates, the comparison becomes distorted. Logs should also record the retry count for each request so retry-driven costs can be analyzed separately.

    6. Practical Recommendations

    • Start with a small task set for quick screening, then run a larger set for the final comparison.
    • Keep the evaluation scripts under version control and rerun them whenever the model or framework version changes.
    • Classify failure cases — insufficient capability, missing context, restricted permissions, and so on — and use the findings to improve prompt strategies or tool configuration.
    • Give selection conclusions an expiration date. Frameworks and models iterate quickly, so re-evaluate quarterly.
    • If the evaluation uses real production code, first confirm that sandbox isolation and data access permissions meet compliance requirements.

    7. Common Pitfalls

    Pitfall 1: Looking only at overall rankings. Rankings do not reflect your team’s task distribution or cost sensitivity, so applying them directly can easily lead to the wrong choice.

    Pitfall 2: Ignoring the cost of failure. The human rework time on failed tasks often exceeds the model invocation fees. The evaluation report should convert rework time into total cost.

    Pitfall 3: Treating a single run as a conclusion. Randomness alone is enough to change rankings across multiple runs; conclusions need statistical support.

    Pitfall 4: Evaluating only the model, not the framework. With the same model, differences in context management and failure recovery strategies often matter more than a model version upgrade.

    8. Conclusion

    The core of evaluating agent frameworks is to look at “can it complete the task” and “how much does it cost to complete it” within a single metric. Fix the experimental conditions, cover realistic task types, run multiple times, and keep complete failure records — and you will get reproducible conclusions that can actually support decisions.