Evaluating AI Coding Agents: Trade-offs Among Pass Rate, Completion, and Cost
Evaluating the capabilities of AI coding agents requires moving beyond single-line generation or algorithmic puzzles. This article explores why engineering tasks provide a more accurate benchmark for real-world development scenarios. It breaks down four core metrics—pass rate, average completion, average time, and cost per run—and examines the trade-offs between them. Additionally, it offers a step-by-step guide to establishing an internal selection process, complete with a Python code example for calculating a weighted composite score.
1. Why Engineering Tasks Matter for Evaluating AI Coding Capabilities
The accuracy of single-line code generation or algorithmic problem solving rarely reflects a developer’s actual experience in real-world projects. Authentic engineering work involves setting up project skeletons, implementing business features, migrating legacy code, and refactoring existing applications to new technical architectures. These tasks span multiple files, require an understanding of module dependencies, and often demand iterative corrections across compilation, testing, and runtime environments. Therefore, benchmarks oriented toward engineering tasks provide a much better indication of whether an agent can deliver results independently.
Mobile app development serves as a typical scenario. UI components, lifecycle management, permission requests, network calls, and local storage are highly coupled; an error in any of these areas can lead to build failures or runtime crashes. Evaluating such tasks requires placing the output into actual build and runtime environments for verification—simply reading the code is insufficient to detect issues.
2. Main Types of Evaluation Tasks
- Engineering Initialization: Generating project structures, configuration files, and base pages based on requirements.
- Feature Development: Adding new features to existing code while ensuring existing behaviors remain unchanged.
- Code Migration: Rewriting code from older APIs or legacy frameworks to new interfaces.
- Application Transformation: Converting an application from one form to another, such as adapting a single-platform app to a multi-platform architecture.
The difficulty varies significantly across these task types. When reviewing evaluation results, it is crucial to first understand the composition ratio of the tasks before comparing specific numbers.
3. Four Core Metrics
3.1 Pass Rate
Pass rate refers to the proportion of tasks that fully meet the acceptance criteria. Acceptance typically includes successful compilation, passing automated tests, and fulfilling all functional checkpoints. The pass rate is a binary judgment of “deliverable or not” and is the most direct metric for deployment decisions.
3.2 Average Completion
Completion measures how much was accomplished for tasks that did not fully pass. A task can be broken down into several checkpoints, and completion is the average ratio of passed checkpoints to total checkpoints. It reflects the agent’s partial delivery capability, helping teams gauge the progress of a task and facilitating a smooth handover for manual continuation.
3.3 Average Time
Time refers to the duration between the agent receiving a task and outputting the final result. This is influenced by model inference speed, the number of tool calls, retry attempts, and waiting for environment feedback. A longer duration usually indicates more trial and error during the process.
3.4 Cost Per Run
Cost refers to the billed resources consumed to complete one evaluation run, generally determined by the number of input and output tokens used for inference calls and their unit prices. When calculating costs, the same set of tasks must be used; otherwise, solutions with different unit prices cannot be fairly compared.
4. Trade-offs Between Metrics
4.1 What High Completion and Long Duration Indicate
When a solution exhibits high completion but a long duration, it typically suggests a tendency to repeatedly verify, add tests, and incrementally fix issues. Such solutions are well-suited for tasks with strict quality requirements where longer wait times are acceptable, such as refactoring core modules. However, if the goal is rapid prototyping, prolonged waiting will slow down the iteration cycle.
4.2 Relationship Between Pass Rate and Cost
A solution with a high pass rate may not necessarily offer the best cost-effectiveness. If two solutions have similar pass rates but vastly different costs per run, teams should calculate the “average cost per passed task,” which is the total cost divided by the number of passed tasks. This metric provides a closer reflection of actual expenses than simply looking at unit price.
4.3 Balancing Speed and Budget
Teams with tight budgets or a need for frequent iterations may prioritize time and cost. Conversely, teams with high security requirements or where rework is expensive should prioritize pass rate and completion. No single set of metrics is optimal for every team; before making a selection, teams must determine the weight of each metric.
5. Establishing an Internal Selection Process
- Define Task Profiles: List the five to ten most common development tasks your team encounters.
- Build Representative Samples: Extract real tasks from historical requirements and provide acceptance scripts for each.
- Standardize the Runtime Environment: Unify dependency versions, timeouts, and retry strategies to prevent environmental discrepancies from skewing results.
- Run Multiple Times and Average the Results: Repeat the same task multiple times and record the range of result fluctuations.
- Calculate Composite Scores: Aggregate metrics according to team-defined weights, and retain raw data for auditing.
- Conduct a Pilot Run: Run the solution in a real project for one or two iteration cycles to confirm effectiveness before deciding on wider adoption.
6. Example Code: Weighted Composite Scoring
The following example first normalizes the four metrics to a range between 0 and 1, then calculates a weighted sum. Since lower time and cost are better, these two metrics are inversely mapped. The weights are for illustrative purposes only; actual values should be set by the team based on their business context.
from dataclasses import dataclass@dataclassclass EvalResult:pass_rate: float # Pass rate, range 0 to 1completion: float # Average completion, range 0 to 1avg_hours: float # Average time in hourscost_per_run: float # Cost per run, in the team's accounting currencydef composite_score(result: EvalResult,max_hours: float,max_cost: float,weights: dict[str, float]) -> float:"""Calculate normalized composite score, range 0 to 1, higher is better."""time_score = 1 - min(result.avg_hours / max_hours, 1.0)cost_score = 1 - min(result.cost_per_run / max_cost, 1.0)weighted_sum = (weights["pass_rate"] * result.pass_rate+ weights["completion"] * result.completion+ weights["time"] * time_score+ weights["cost"] * cost_score)return weighted_sum / sum(weights.values())def cost_per_pass(total_cost: float, passed_count: int) -> float:"""Average cost per passed task, used to compare cost-effectiveness."""if passed_count == 0:return float("inf")return total_cost / passed_countif __name__ == "__main__":weights = {"pass_rate": 0.4, "completion": 0.2, "time": 0.2, "cost": 0.2}sample = EvalResult(pass_rate=0.5, completion=0.8,avg_hours=6.0, cost_per_run=120.0)score = composite_score(sample, max_hours=24.0, max_cost=500.0,weights=weights)print(f"Composite score: {score:.3f}")
The value of this script lies in translating selection criteria into auditable code. Teams can adjust the weights to observe if the ranking changes, thereby determining whether the conclusion is sensitive to the weights.
7. Practical Considerations
- Impact of Peripheral Frameworks: Benchmark scores depend not only on the underlying model but also on prompt organization, tool permissions, and context management. When comparing different solutions, ensure peripheral conditions are consistent, or clearly state the differences in the report.
- Sample Size Limitations: With a small sample size, the confidence interval for the pass rate is wide. Minor differences in a single evaluation should not be over-interpreted.
- Public Benchmarks vs. Private Tasks: The task distribution of public benchmarks may not align with the team’s business needs. Final decisions should be based on internal representative samples.
- Timeliness of Cost: Billing strategies and concurrency conditions change over time; the report should note the date of statistics collection.
- Verification is Mandatory: Generated code still needs to undergo code review, security scanning, and real device or emulator testing. A high score does not mean these steps can be skipped.
