Evaluating AI Coding Agents on Long-Horizon Tasks: Key Metrics and Cost Trade-offs
This article examines how to evaluate AI coding agents on long-horizon software engineering tasks, using a recent mobile app development benchmark as a reference point. It breaks down four metrics that are easy to misread—pass rate, average completion, average runtime, and cost per run—and explains why a high completion score can mask a low pass rate and hidden human handoff costs. It shows where large cost gaps between model-and-scaffold combinations come from, how to build your own evaluation harness instead of copying a public leaderboard, how to integrate agents into a delivery pipeline with proper isolation and least privilege, and which cost and stability guards are non-negotiable: budget caps, no-progress detection, tiered routing, and context caching. You get concrete cost-estimation formulas, sample task-definition and scoring code, a pitfalls checklist, and an action plan for measuring cost per unit of effective delivery.
Why a Benchmark Update Belongs in a Technical Retrospective
A mobile operating system’s official developer channel recently published a batch of results for coding agents on a mobile app development benchmark. This benchmark is not an algorithm puzzle or a function-level completion test. It is built around four categories of real engineering work—app creation, feature development, code migration, and app conversion—and it is a long-horizon evaluation: each task requires the agent to work autonomously inside a complete repository, read code, plan steps, call tools across many rounds, modify dozens of files, and finally pass automated acceptance checks.
The value of results like these to engineering teams is not “who ranks first.” It is that, for the first time, they quantify one thing with reproducible cost data: having an agent independently complete a medium-complexity development task operates on a time scale of hours and a monetary scale of tens to thousands of RMB. That order of magnitude directly determines whether such agents can enter your delivery pipeline, and in what posture.
It is worth stressing the benchmark’s control-variable problem: in the published results, each score comes from a “model + agent scaffold” combination, and different combinations use different agent frameworks. This means the leaderboard measures end-to-end delivery capability, not raw model intelligence. The scaffold handles context organization, the tool-calling loop, failure retries, and checkpoint management, and its contribution to the final score is routinely underestimated. Any attempt to “copy the leaderboard ranking to pick a model” ignores this layer entirely.
First, Define It: What Counts as a “Long-Horizon Task”
The fundamental difference between short tasks and long-horizon tasks lies in context lifecycle:
- Short tasks (completing a function, writing a unit test, fixing one error): the context can be loaded within a single interaction, the failure cost is roughly one retry, and a human can correct course immediately.
- Long-horizon tasks: the context must be maintained across dozens of tool calls; intermediate state (which files have been changed, which tests fail, where the build artifacts are) must be carried by external memory or checkpoints; the failure cost is roughly several hours of machine time plus one round of human takeover; and the correction window is measured in hours.
Long-horizon tasks therefore introduce three problems that short tasks do not have:
- Context drift: as edits accumulate, the agent’s understanding of the “task goal” gets contaminated by intermediate artifacts, and it drifts further off course the more it changes.
- Deferred verification: errors often surface only after dozens of steps (compile failures, end-to-end crashes), by which point rollback is expensive.
- Unbounded resources: without a budget guard, an agent stuck in a loop can keep consuming until a human notices.
Understanding these three points is what explains why an evaluation should record both time and cost, rather than just “how many it got right.”
Four Metrics, Four Very Different Readings
3.1 Pass Rate: Strict Binary Acceptance
Pass rate = number of tasks passing all hard acceptance checks / total number of tasks. It is binary: if the build fails, a critical test fails, or a file marked as off-limits was touched, any one of these makes the task a fail. It has zero tolerance for “almost there.”
In the public data, the highest pass rate is 28.7%, the second is 24.0%, and one lower group is at 17.3%. Note the absolute level of these numbers—even the best combination stably delivered less than one-third of 30 long-horizon tasks. This is the most direct cold water on claims like “agents can replace junior engineers.”
3.2 Average Completion: A Continuous Progress Bar
Average completion measures “how far the task was pushed,” computed as a weighted score over fine-grained acceptance items: code that is correct but missing one edge-case branch, a migration that finished 90% of the call sites, or a conversion whose UI works but whose theme resources are not adapted—all of these score zero on pass rate yet can score high on completion.
This is exactly what produces the “high completion + low pass rate” combination. In the public data, one group scored a 24.0% pass rate with an 82.3% average completion, and another scored a 17.3% pass rate with a 71.2% average completion. Reading completion as if it were pass rate is the most common selection mistake: an 82.3% completion in business terms means “it looks done, but someone still has to take over and finish it,” and the cost of finishing is often more than half of starting from scratch.
The engineering implications are clear:
- Pass rate determines whether a change can be auto-merged unattended;
- Completion determines how much a human must fill in during collaboration;
- The gap between the two is the “human-takeover tax.”
3.3 Average Runtime: The Long Tail Hidden by the Mean
In the public data, the two groups’ average runtimes are 27.4 hours and 12.0 hours—about a 2.3x difference. But “average runtime” almost inevitably hides a long tail in long-horizon tasks: a few tasks may get stuck retrying repeatedly and consume the bulk of the total time.
Companies building their own evaluation should therefore collect additional data:
- P50 / P90 runtime, not the mean;
- A distribution of tool-call rounds, to identify whether no-progress loops occur;
- The number and duration of human interventions, an item that public leaderboards ignore completely but that accounts for a very large share of cost.
A runtime on the order of 27.4 hours also means something else: these tasks must be designed as asynchronous, unattended jobs, with checkpoint resume, interruptible retries, and stage artifacts written to disk—not left running in some interactive terminal waiting for someone to watch it.
3.4 Cost per Run: The Real Gate
In the public data, the cost of a single benchmark run is $317.4 and $9.9, respectively—about a 32x difference. These two data points let us do two more informative conversions:
| Metric | High-Completion Combination | Low-Cost Combination |
|---|---|---|
| Pass rate | 24.0% | 17.3% |
| Average completion | 82.3% | 71.2% |
| Average runtime | 27.4 h | 12.0 h |
| Cost per run | $317.4 | $9.9 |
| Cost per passed task | ≈ $44.1 | ≈ $1.9 |
| Cost per machine-hour | ≈ $11.6 | ≈ $0.83 |
“Cost per passed task” is the comparable metric: 30 × 24.0% ≈ 7.2 tasks, 317.4 / 7.2 ≈ $44.1; 30 × 17.3% ≈ 5.2 tasks, 9.9 / 5.2 ≈ $1.9. The unit cost of effective delivery differs by about 23x, while the pass rate differs by only 1.4x. This is the core engineering trade-off of the “high-completion, long-runtime” route: it spends 32x the bill and 2.3x the time to buy 1.4x the pass rate and 11 percentage points of completion.
Whether that trade is worth it depends entirely on the nature of the task:
- One-off, high-value, cannot-afford-mistakes tasks (core-path migrations, payment/compliance-related changes): Buy it. Several days of human handoff plus error risk far outweigh the ~$317 machine-time fee.
- High-frequency, tolerable, human-backstop tasks (boilerplate code generation, copy and asset replacement, batch dependency version upgrades, test supplementation): Don’t buy it. About $9.9 per run plus 20 minutes of human touch-up is optimal on unit cost.
- Exploratory tasks (solution pre-research, feasibility validation): Prefer the low-cost route and save the budget for post-pass refinement.
Where the 32x Cost Gap Comes From: Anatomy of the Bill
The gap is not simply “a different unit price.” The cost of a long-horizon task is made up of five main parts:
- Re-billing input on every round: each round of tool calls must reload the context (repository structure, files already read, prior decisions). The more rounds, the more times the same code is billed again; input tokens often make up the bulk of total consumption.
- Length of thinking and output: long-chain reasoning and generation are costly in themselves, and correlate with task complexity at roughly a superlinear rate.
- Sunk cost of failed retries: all failed tasks are billed in full. If the pass rate is 17.3%, that means roughly 83% of the machine-time budget was spent on tasks that did not pass—the item most easily overlooked in budget planning.
- Tool and retrieval overhead: code search, dependency analysis, build and test execution, screenshot and log read-back—every step has waiting and data-processing costs.
- The hidden cost of human review: the long-runtime route produces longer outputs and larger change surfaces, so the attention cost of code review is higher too.
A simplified model for internal estimation:
cost per task ≈ (input tokens per round × rounds + output tokens per round × rounds) × unit price+ tool execution cost+ failed retries × cost per runmonthly team cost ≈ number of tasks × cost per task / pass rate # note the divide by pass rate
The last step is the key point: to deliver N passing results, you must budget for N / pass rate, not N. At pass rates of 24% and 17.3%, the latter needs about 39% more invocations; stacking that on top of differences in unit price and rounds produces a total-bill gap of two orders of magnitude.
Building Your Own Evaluation: Copy the Method, Not the Leaderboard
The task sets, acceptance scripts, and prompts behind a public leaderboard are not in your repository, and its conclusions do not transfer directly. The right approach is to build your own evaluation system.
5.1 Task Set Design
Sample from your real backlog, cross-stratify by the four task categories and three difficulty layers, put 3–5 tasks in each cell, and keep the total at 40–60 tasks so a full round finishes within a day:
| Task Category | Description | Difficulty Layer |
|---|---|---|
| App creation | Generate a minimal buildable app from an empty repository | Few dependencies, objective acceptance; good for an entry-level baseline |
| Feature development | Add an end-to-end feature to an existing project | Requires understanding existing architecture and conventions |
| Code migration | Framework/language/dependency upgrade with behavior preserved | Highest regression risk |
| App conversion | Cross-platform / cross-form-factor adaptation | Hardest to define acceptance; high share of manual spot-checking |
Three design principles: acceptance must be automated and unambiguously binary; keep a private held-out set for each task (excluded from any tuning) to detect evaluation-data contamination; and write task descriptions in natural language with explicit acceptance conditions—do not “feed” implementation steps in the prompt, or you are testing the prompt rather than the agent.
5.2 Sample Task Definition
task_id: MOB-014category: feature_devstatement: |Add an "offline draft" capability to an existing mobile project: locally persistedited content when the network is interrupted, and automatically merge conflictswhile preserving both sides' changes after the network is restored.acceptance:build: { command: "$BUILD_CMD" } # build toolchain is injected uniformly by the task imagestatic_check: { command: "$LINT_CMD", must_pass: true }unit_tests: { min_pass_rate: 1.0 } # hard gatee2e_scenarios: ["draft_restore_after_kill", "conflict_merge_no_data_loss"]diff_limits: { max_files_changed: 25, forbidden_paths: ["build/", ".ci/"] }budgets:wall_clock_hours: 6cost_usd: 8.0max_tool_calls: 400
diff_limits is often ignored, but it is very effective: a runaway change surface or edits to CI configuration are the most common early warning signs of an agent exceeding its authority.
5.3 Scoring and Gating
def score(run) -> dict:"""Return {'pass': bool, 'completion': float}"""checks = run.acceptance_reporthard = [c for c in checks if c.weight is None] # build / unit tests / security: hard gatescored = [c for c in checks if c.weight is not None]passed = all(c.ok for c in hard)completion = sum(c.weight * c.ratio for c in scored) / sum(c.weight for c in scored)overspent = run.cost_usd > run.budget_usd or run.elapsed_h > run.budget_hreturn {"pass": passed and not overspent, "completion": completion}
For the gating strategy, use two thresholds rather than a single one, separating “can be auto-merged” from “give a suggestion only”:
POLICY = {"auto_merge": {"min_pass_rate": 0.45, "min_completion": 0.80,"max_cost_per_pass_usd": 10}, # cap on unit cost of effective delivery"assist_only": {"min_completion": 0.55}, # generate a suggestion only; apply after human confirmation"reject": {}, # completion too low; do not enter the human workflow}
The thresholds must be calibrated against your own historical data: first run a baseline, measure the joint distribution of pass rate and completion, then set the auto_merge pass-rate gate at the point where the human spot-check defect rate is acceptable. Copying someone else’s 28.7% or 24% directly is meaningless.
Plugging Agents into the Delivery Pipeline: Isolation and Permissions First
Before letting an agent write code, nail down the boundaries:
- Repository isolation: use a dedicated mirror repository or a separate branch, prohibit direct commits to the mainline; all output enters as pull requests, and branch protection rules apply as usual.
- Sandboxed execution: run tasks in disposable container sandboxes with limits on CPU/memory/runtime and no access to production credentials; all builds, tests, and artifact uploads happen inside the sandbox.
- Least privilege: grant only the minimum credential scope a task needs, keep keys short-lived, and prohibit arbitrary outbound network access.
- Full-chain traceability: write every round’s tool-call inputs and outputs, every file change, and every acceptance result to disk, so any run can be replayed after the fact.
- Artifact archiving and rollback: archive build artifacts, evaluation reports, and diffs uniformly, with the ability to trace back by task_id and run batch.
On the cloud side, this can be assembled entirely from general-purpose capabilities rather than a single vendor-specific solution: use object storage to archive build artifacts and evaluation reports, a container platform to host isolated sandboxes with elastic scaling, a message queue to turn long-running tasks into asynchronous jobs that smooth out peaks and fill valleys, a logging service to retain call traces for auditing, and monitoring/alerting to set thresholds on machine time and failure rates. Baidu AI Cloud, for example, offers corresponding product categories for each of these general-purpose capabilities (object storage, container platform, message queue, logging service, monitoring/alerting) that can be combined as needed, without introducing proprietary components dedicated to the evaluation system.
Cost and Stability Governance: Four Guards You Must Have
7.1 Budget Guard (Hard Cap + Soft Warning)
```python
class BudgetGuard:
“””Executed before any model/tool call; interrupt and save a checkpoint when the cap is exceeded”””
def init(self, hard_cap_usd: float, soft_ratio: float = 0.7):
self.hard_cap, self.soft_ratio = hard_cap_usd, soft_ratio
self.warned = False
def before_call(self, ctx) -> None:if ctx.cost_usd >= self.hard_cap:ctx.checkpoint_and_stop(reason="budget_exceeded")elif not self.warned and ctx.cost_usd >= self.hard_cap * self.soft_ratio:ctx.emit_alert(level="warning", spent=ctx.cost_usd)self.war
