Long-Horizon AI Coding Evaluation: Pass Rates, Costs, and Security Practices

    A new wave of AI coding benchmarks shifts the question from "can a model write one correct function" to "can an agent complete an entire loop—requirements analysis, code generation, compilation, testing, and failure recovery—over a long run." This article reads a set of sample results from a mobile-app development benchmark to show how task pass rate, average completion, latency, and cost move together, and why a single pass-rate number is not enough to judge production usability. It breaks down four core metrics, provides a reproducible evaluation pipeline built on task sets, isolated containers, and automated scoring with working code, offers a cost model that separates cached tokens from retries and environment overhead, and closes with practical guidance on model selection, cost reduction, and common pitfalls. Values are treated as illustrative sample data, and real leaderboards should be cited from their official source.

    1. Introduction: Long-Horizon Coding Tasks Become the New Yardstick

    Recently, a mobile-app development benchmark published a new round of results. Unlike earlier evaluations, long-horizon AI coding tasks no longer just test whether a model can generate one correct function. Instead, they test whether an agent can complete a full closed loop over an extended period: requirements analysis, code generation, compilation and build, test execution, and failure recovery. For engineering teams, the value of these leaderboards is not only the ranking. More importantly, they help teams answer three questions: How far have model capabilities advanced? Are latency and cost falling at the same time? Do different price tiers offer a better cost-to-performance ratio?

    In practice, teams often ask: How should AI coding evaluation be done? How should long-horizon task cost be calculated? How should AI coding models be selected? Looking at pass rate alone can easily misjudge a model’s production usability, while looking at unit price alone can overlook context accumulation, failure retries, and environment overhead in long-horizon tasks.

    First, a note on the data. Because the complete source page, sample size, and original definitions were not available, the leaderboard figures cited here should be understood as “sample data.” The sample conventions are: published in June 2025; a task sample size of 100 long-horizon coding tasks; one run per task; a task counts as passing when the agent completes the implementation in a single pass and passes all builds and tests in an isolated environment; costs are in USD; and the cost scope includes model inference calls, compilation and execution, test execution, dependency downloads, and other environment resource consumption. If you later cite a real leaderboard, defer to the official publication page for the task set version, pass criteria, cost definition, and sample size.

    2. Reading the Signals: Three Takeaways from the Update

    Object Task pass rate Avg task completion Avg latency per run Avg cost
    Previous-generation model 12.0% Not provided 66.2 hours $418.3
    New-generation model 24.0% 82.3% 27.4 hours $317.4
    Lightweight fast model 17.3% Not provided 12.0 hours $9.9

    Note: To illustrate the ceiling of top-end capability, the top model in the sample leaderboard has a pass rate of 40.0%. This uses the same convention as the table above, but the top model’s completion was not separately provided in this sample.

    2.1 Capability gains: pass rate doubles, but overall difficulty stays high

    The new-generation model’s pass rate is 24.0%, roughly twice the previous generation’s 12.0%. This confirms that long-horizon coding ability is advancing quickly. But from an engineering-delivery perspective, 24.0% means about three-quarters of tasks still fail to pass all acceptance criteria on the first attempt. Even the top model’s 40.0% pass rate in the sample shows that “delivering a runnable application end to end” remains an unsolved problem.

    A single score cannot be equated with production usability. In long-horizon tasks, a model can make small mistakes in multi-file changes, dependency management, error recovery, and final verification, and any of these can fail the whole task. Pass rate is good for measuring the capability ceiling and stability, but it alone cannot answer “can this go to production?”

    2.2 Efficiency gains: latency drops sharply, but unit-time cost rises

    Average latency per run fell from 66.2 hours to 27.4 hours, a decrease of:

    1. (66.2 - 27.4) / 66.2 ≈ 58.6%

    So the new-generation model’s per-run latency is nearly half that of the previous generation.

    But average cost fell from $418.3 to $317.4, a decrease of:

    1. (418.3 - 317.4) / 418.3 ≈ 24.1%

    The latency reduction is clearly larger than the cost reduction. Computing the unit-time cost:

    1. unit-time cost = average cost / average latency per run
    Object Avg cost Avg latency per run Unit-time cost
    Previous-generation model $418.3 66.2 hours $6.3/hour
    New-generation model $317.4 27.4 hours $11.6/hour

    The increase in unit-time cost is:

    1. (11.6 - 6.3) / 6.3 ≈ 83%

    So one common misreading needs a correction here: the new-generation model is not one where “unit-time cost drops,” nor is it “rising by only about 50%.” Unit-time cost actually rises by about 83%, close to 80%.

    This change usually has two causes. First, optimization concentrates on “reducing wasted work”—fewer ineffective rollbacks, less repeated trial and error, and fewer ineffective patches—so latency drops noticeably. Second, the per-token inference price does not fall in step, and may even be higher. In long-horizon tasks, model inference is the common source of both latency and billing, so evaluation and model selection cannot look only at “how much faster” or “how much cheaper,” but must also look at hourly cost, cost per pass, and task completion quality.

    2.3 The lightweight model: extremely low cost, strong per-dollar pass rate

    The lightweight fast model’s pass rate is 17.3%, about 72% of the new-generation model’s 24.0%. Its average latency per run is 12.0 hours and its average cost is $9.9.

    Another common misreading needs correction here: the lightweight fast model’s cost is not “under 3% of the new-generation model,” but about 3.1% of it. The calculation:

    1. 9.9 / 317.4 ≈ 3.1%

    To further measure the pass rate bought per unit cost using “pass rate ÷ average cost,” compute with pass rate as a decimal:

    1. New-generation model: 0.24 / 317.4 ≈ 0.000756
    2. Lightweight model: 0.173 / 9.9 ≈ 0.0175

    The latter is about 23 times the former.

    This means that for a large number of clearly bounded, well-specified routine tasks, the lightweight model may offer significant cost-performance advantages. But for architecture design, complex refactoring, and hard-to-locate defects, you still need to weigh pass rate, completion, and human review cost together. The key to long-horizon AI coding evaluation is not simply choosing the “strongest model,” but choosing the “right model” by task tier.

    3. Breaking Down the Metrics: Four Rulers for Long-Horizon Evaluation

    Long-horizon coding evaluations usually include four core metrics: task pass rate, average task completion, average latency, and average cost. Each answers a different question.

    3.1 Task pass rate: can it get done in one shot

    Task pass rate usually refers to the proportion of tasks that fully pass all acceptance criteria in a single complete run. These benchmarks generally require the output to compile and build, run tests, and pass them all, so a mistake at any stage fails the whole task. It is a strict binary metric, more reflective of the model’s capability ceiling and stability.

    If multiple sampling is used with “any success counts as a pass,” the pass rate is usually noticeably higher, because multiple samples raise the probability of “succeeding by chance.” So when reading a leaderboard, confirm the sampling count: is it a single run, or multiple samples taking the best result?

    3.2 Average task completion: how far it gets

    Average task completion is usually computed from the completion of functional points, test cases, or other checks decomposed from the requirements—for example, the proportion of passed checks to all checks. It measures “how much” the model did.

    The new-generation model’s average completion is 82.3%, but its pass rate is only 24.0%. The gap between the two deserves attention. Reasons include: First, failed tasks are unevenly distributed across the model population and the task population, so completion and pass rate cannot be simply divided. Second, even when a task is “completed,” average completion is only around 80%. Third, the real difficulty of long-horizon tasks is often in the final wrap-up, verification, and error-recovery stages.

    For example: a task has 10 acceptance checks and the model completes 9, so completion can be recorded as 0.9, but if the last end-to-end acceptance check fails, the task pass rate is still 0. So being close to completion is not the same as passing. Completion is better used as an observation signal during optimization, while pass rate is the delivery conclusion.

    3.3 Average latency: how long to wait

    Average latency refers to the wall-clock time of a single complete evaluation run, covering model inference, compilation, execution, testing, and repeated iteration after failures. It mainly reflects the agent loop’s efficiency, including whether planning is reasonable, whether feedback is correctly absorbed, and whether ineffective rollbacks are frequent.

    The new-generation model’s latency is still about 2.3 times the lightweight model’s:

    1. 27.4 / 12.0 ≈ 2.3

    If complex tasks require long unattended runs, scheduling, timeouts, budgets, and interruption mechanisms must be designed in advance. Otherwise, long tasks can slow down the whole R&D process, or reduce willingness to use them because of long waits.

    3.4 Average cost: how much to spend

    Average cost is usually determined by token consumption and billing rates; companion resource consumption such as code execution, dependency downloads, and test execution should also be included. Long-horizon task cost has a “cumulative amplification” characteristic: every round of interaction carries historical context, so input tokens grow with the number of conversation turns; every failure retry stacks new cost on top of already-consumed cost.

    As a result, cost growth is often faster than the growth in the task’s own complexity. So average cost cannot look only at per-call price, but must look at the whole task budget.

    Overall, pass rate answers “can it get done,” completion answers “how far it gets,” latency answers “how long to wait,” and cost answers “how much to spend.” Only combining all four restores a model’s real performance in a given scenario.

    4. Engineering Practice: Building a Reproducible Long-Horizon Coding Evaluation

    Public leaderboards and your own business scenarios often differ. The agent’s run limits, the environment where the tested code runs, languages and frameworks, dependency versions, network policies, and timeout settings all affect the final result. If a team wants to select models scientifically, it should build its own evaluation pipeline. The core has three parts: task sets, isolated environments, and automated scoring.

    4.1 Task set design

    An effective task set should meet these conditions:

    • Difficulty tiers: divide into simple fixes, multi-file feature development, and complex refactoring, so overall scores are not diluted by simple tasks.
    • Diverse sources: optionally use historical defect fixes, internal requirement implementation, or building small apps from scratch, to stay close to real work.
    • Automatically verifiable: each task comes with clear acceptance criteria, e.g., “build succeeds + specified tests all pass.”
    • Regular updates: prevent the task set from staying unchanged long enough to be “gamed,” and avoid task information entering the model through training data.
    • Version recording: task sets, acceptance commands, and expected results should all be under version control, ensuring comparability and traceability across different models.

    4.2 Isolated environment and security boundaries

    Each task should run in an independent container to guarantee reproducibility, concurrency, and recyclability. Beyond traditional environment isolation, add security boundaries:

    • Network isolation: disallow external network access by default; only allow access to controlled dependency sources or whitelisted services.
    • Read-only mounts: mount base images, toolchains, and test dependencies read-only where possible, to avoid the tested agent modifying the evaluation environment.
    • Resource limits: cap CPU, memory, disk, process count, and run time to prevent resource exhaustion.
    • Avoid executing untrusted commands: especially avoid directly concatenating strings to run arbitrary shell commands. In production, use command whitelists, fixed arguments, and in-container safe-execution policies.
    • Artifact cleanup: after a task ends, uniformly reclaim containers and temporary directories to avoid leftovers contaminating the next round.

    A minimal executable example follows. The command creates an internal network, disables external access inside the container, mounts the root filesystem read-only, uses tmpfs for the working directory, and limits CPU, memory, and process count:

    1. docker network create --internal bench-net
    2. docker run --rm \
    3. --network bench-net \
    4. --read-only \
    5. --tmpfs /tmp:rw,exec \
    6. --tmpfs /workspace:rw,exec \
    7. --cpus=2 \
    8. --memory=2g \
    9. --pids-limit=256 \
    10. --security-opt no-new-privileges \
    11. --cap-drop=ALL \
    12. --user 1000:1000 \
    13. --workdir /workspace \
    14. bench-image

    If you need to access a controlled dependency source, it is not advisable to open the public network directly; instead, start an internal proxy that only the evaluation container can reach. For example:

    1. docker run -d --name bench-proxy \
    2. --network bench-net \
    3. --restart=no \
    4. bench-proxy
    5. docker run --rm \
    6. --network bench-net \
    7. -e HTTP_PROXY=http://bench-proxy:3128 \
    8. -e HTTPS_PROXY=http://bench-proxy:3128 \
    9. --read-only \
    10. --tmpfs /workspace:rw,exec \
    11. --cpus=2 --memory=2g --pids-limit=256 \
    12. --security-opt no-new-privileges --cap-drop=ALL \
    13. --user 1000:1000 \
    14. --workdir /workspace \
    15. bench-image

    Task run time can be controlled via the evaluation script’s timeout, or via an external timeout tool at the orchestration layer:

    1. timeout 8h python -m your_evaluator

    Time-consuming steps like dependency installation and data preparation should be completed in advance and baked into the image, so they don’t interfere with measuring model capability.

    4.3 Automated scoring and minimal reproducible code

    The tested agent needs a clear entry point. Recommended convention: for each task, call python -m agent_runner <instruction>, generate code artifacts in the task directory, and print a usage JSON on the last line of stdout. The usage JSON should contain at least these fields:

    1. {
    2. "input_tokens": 1000,
    3. "output_tokens": 200,
    4. "cost": 0.01
    5. }

    Exit code convention: 0 means the agent ended normally; non-zero means the agent exited abnormally. Whether or not the exit code is 0, the final pass decision is based on the unified acceptance result.

    A minimal runnable agent_runner.py example follows:

    1. # agent_runner.py
    2. import argparse
    3. import json
    4. import os
    5. import sys
    6. def main() -> int:
    7. parser = argparse.ArgumentParser()
    8. parser.add_argument("instruction")
    9. args = parser.parse_args()
    10. # A real implementation would call the model, modify code, or generate files here.
    11. # This example only writes a single task artifact to demonstrate the minimal loop.
    12. with open("agent_output.txt", "w", encoding="utf-8") as f:
    13. f.write(args.instruction + "\n")
    14. usage = {
    15. "input_tokens": 1000,
    16. "output_tokens": 200,
    17. "cost": 0.01,
    18. }
    19. print(json.dumps(usage, ensure_ascii=False))
    20. return 0
    21. if __name__ == "__main__":
    22. sys.exit(main())

    The core requirements of the evaluation script: do not use shell=True; run acceptance commands via argument lists; only allow whitelisted programs; use timeout limits; and parse the usage JSON from output. Example code:

    1. import asyncio
    2. import json
    3. import os
    4. import shlex
    5. import subprocess
    6. import time
    7. ALLOWED = {"python", "python3", "pytest", "node", "npm"}
    8. def to_argv(cmd):
    9. if isinstance(cmd, (list, tuple)):
    10. argv = list(cmd)
    11. else:
    12. argv = shlex.split(cmd)
    13. if not argv or os.path.basename(argv[0]) not in ALLOWED:
    14. raise ValueError(f"disallowed command: {cmd}")
    15. return argv
    16. def parse_usage(raw: str) -> dict:
    17. for line in reversed(raw.splitlines()):
    18. line = line.strip()
    19. if line.startswith("{"):
    20. try:
    21. return json.loads(line)
    22. except json.JSONDecodeError:
    23. continue
    24. return {}
    25. def verify(workdir: str, checks: list[str]) -> tuple[bool, float, str]:
    26. ok = 0
    27. failure = ""
    28. for cmd in checks:
    29. argv = to_argv(cmd)
    30. try:
    31. proc = subprocess.run(
    32. argv,
    33. cwd=workdir,
    34. shell=False,
    35. capture_output=True,
    36. text=True,
    37. timeout=1800,
    38. )
    39. if proc.returncode == 0:
    40. ok += 1
    41. else:
    42. failure = proc.stderr.strip() or proc.stdout.strip() or cmd
    43. except Exception as exc:
    44. failure = str(exc)
    45. passed = ok == len(checks)
    46. completion = ok / max(1, len(checks))
    47. return passed, completion, "" if passed else failure
    48. async def run_task(task_id: str, instruction: str, sandbox: str,
    49. checks: list[str], time_limit: int = 8 * 3600) -> dict:
    50. workdir = os.path.join(sandbox, task_id)
    51. os.makedirs(workdir, exist_ok=True)
    52. start = time.monotonic()
    53. proc = await asyncio.create_subprocess_exec(
    54. "python",
    55. "-m",
    56. "agent_runner",
    57. instruction,
    58. cwd=workdir,
    59. stdout=asyncio.subprocess.PIPE,
    60. stderr=asyncio.subprocess.STDOUT,
    61. )
    62. loop = asyncio.get_running_loop()
    63. timer = loop.call_later(time_limit, proc.kill)
    64. try:
    65. stdout, _ = await proc.communicate()
    66. finally:
    67. timer.cancel()
    68. elapsed = time.monotonic() - start
    69. raw = stdout.decode(errors="ignore")
    70. usage = parse_usage(raw)
    71. passed, completion, failure = verify(workdir, checks)
    72. if proc.returncode != 0:
    73. failure = f"agent exit {proc.returncode}: {failure}"
    74. return {
    75. "task_id": task_id,
    76. "passed": passed,
    77. "completion": completion,
    78. "elapsed_s": elapsed,
    79. "input_tokens": usage.get("input_tokens", 0),
    80. "output_tokens": usage.get("output_tokens", 0),
    81. "cost": usage.get("cost", 0.0),
    82. "failure": failure,
    83. }

    Call example:

    1. checks = [
    2. ["python", "build_app.py"],
    3. ["pytest", "-q"],
    4. ]
    5. result = asyncio.run(
    6. run_task(
    7. task_id="task_001",
    8. instruction="Implement the login page and pass the tests",
    9. sandbox="/tmp/bench_sandbox",
    10. checks=checks,
    11. )
    12. )
    13. print(json.dumps(result, ensure_ascii=False, indent=2))

    Key points of the above skeleton:

    • Use shell=False and argument lists to run acceptance commands, reducing command-injection risk;
    • Use a whitelist to restrict executable programs; in production, still pair with read-only containers, network isolation, and resource limits;
    • Use timeouts and container kill to bound long-task run time;
    • Use communicate() to read subprocess output, avoiding blocking from a full pipe buffer;
    • Include build, test, and usage statistics in a unified result, for later cost analysis and model selection.

    5. Cost Modeling: Where the Money Goes on Long Tasks

    To avoid variable-definition conflicts, this article states clearly: I_in is the total input tokens, and I_cache is the portion of those that hit the cache. So I_cache must not be treated as extra input and added again. If P_in and P_out are in “USD per 1K tokens,” the cost formula is:

    1. C = ((I_in - I_cache) * P_in + I_cache * P_in * d + O * P_out) / 1000 * (1 + r) + C_env

    Where:

    • I_in: total input tokens;
    • I_cache: the portion of total input tokens that hit the cache;
    • O: output tokens;
    • P_in: price per 1K input tokens;
    • P_out: price per 1K output tokens;
    • d: cache-hit discount rate, between 0 and 1;
    • r: average failure-retry factor;
    • C_env: environment overhead such as compilation and testing.

    Suppose a task:

    • I_in = 2,000,000 tokens;
    • I_cache = 1,000,000 tokens;
    • O = 50,000 tokens;
    • P_in = $0.005 per 1K tokens;
    • P_out = $0.02 per 1K tokens;
    • C_env = $2.

    When cache-hit discount d = 0.5 and failure-retry factor r = 0.2:

    • Non-cached input cost = (2,000,000 - 1,000,000) / 1000 × 0.005 = $5;
    • Cache-hit input cost = 1,000,000 / 1000 × 0.005 × 0.5 = $2.5;
    • Output cost = 50,000 / 1000 × 0.02 = $1;
    • Base cost = 5 + 2.5 + 1 = $8.5;
    • With-retry cost = 8.5 × (1 + 0.2) = $10.2;
    • Total cost = 10.2 + 2 = $12.2.

    If the cache-hit discount is raised to d = 0.2, the cache cost drops to:

    1. 1,000,000 / 1000 × 0.005 × 0.2 = $1

    Base cost becomes:

    1. 5 + 1 + 1 = $7

    With-retry cost:

    1. 7 × 1.2 = $8.4

    Total cost:

    1. 8.4 + 2 = $10.4

    If the failure-retry factor is lowered to r = 0.1, with d = 0.5:

    1. With-retry cost = 8.5 × 1.1 = $9.35
    2. Total cost = 9.35 + 2 = $11.35

    This example shows that both the cache-hit discount and the failure-retry factor significantly affect total cost. From this we can derive three cost-reduction levers:

    • Control context growth: summarize and compress completed historical steps, keeping only information relevant to the current decision.
    • Use caching well: stable system prompts, project conventions, and code context have higher hit rates, directly diluting input cost.
    • Reduce retry counts: make acceptance criteria clearer, expose “problems only found at runtime” earlier, and reduce whole-round re-runs.

    Also, per-unit prices vary by tens of times across models, so comparing “USD per million tokens” alone can be misleading. A more reasonable approach is to use metrics like “pass rate per dollar” or “cost per successful task” for selection.

    6. Interpreting Results and Engineering Recommendations

    6.1 Avoid three pitfalls

    • High score does not mean directly usable: public benchmark tasks are fixed, and a model may “memorize” more than “reason” on similar tasks, with overfitting and data-contamination risk.
    • Pass rate does not equal quality: compiling and passing tests is only the baseline; code readability, security, and architectural soundness still need human review.
    • High completion does not mean near success: average completion of 82.3% with a pass rate of only 24.0% shows that long-task failures often concentrate in the final verification stage.

    6.2 How to select models for AI coding evaluation?

    Start from four questions:

    1. Is the task well-bounded? For well-bounded routine tasks, try the lightweight model first.
    2. Does it need long autonomous runs? Long tasks need stronger planning, error correction, and stability.
    3. Is the cost of a single failure high? If human repair cost is high, you can accept a higher-quality but more expensive model.
    4. Do you have a real evaluation set? Without your own set, leaderboards are only a reference and cannot directly replace business validation.

    In practice, a workable approach is to try the lightweight model first; if acceptance fails or it fails to converge after several attempts, escalate to a stronger model. This tiered routing balances cost and success rate.

    6.3 How to cut cost?

    Beyond optimizing context and cache hit rate, cut cost from the process side:

    • Set clear acceptance criteria for tasks to reduce repeated changes caused by vague requirements;
    • Use lightweight models for simple tasks and concentrate strong models on complex tasks;
    • Record each task’s input, output, latency, and cost, and continuously analyze anomalous tasks;
    • Reuse historical successful cases to reduce repeated exploration;
    • Build caches and templates for high-frequency calls to reduce ineffective context consumption.

    6.4 What are the common mistakes?

    • Looking only at pass rate, not completion and failure reasons;
    • Looking only at model unit price, not pass rate per dollar;
    • Looking only at leaderboard ranking, not validating your own business tasks;
    • Miscomputing cache hit rate, double-counting cached tokens in input cost;
    • Mixing unit-cost definitions, e.g., conflating total cost with unit-time cost;
    • Inconsistent sampling counts, making pass rates incomparable across models;
    • Ignoring environment differences, making results non-reproducible;
    • Letting the agent run arbitrary commands directly in an untrusted environment;
    • No timeouts, resource limits, and cost monitoring, letting long tasks spiral out of control.

    6.5 Build an observable evaluation platform

    To keep evaluation results usable over time, teams should gradually build a lightweight but complete evaluation platform. The minimum viable component list includes:

    • Containers and sandbox: host isolated run environments;
    • Object storage: store code artifacts and run logs;
    • Message queue: handle task distribution and result aggregation;
    • Logging service: record agent output, command execution, and exception info;
    • Monitoring and alerting: track latency, failure rate, and cost anomalies;
    • Permissions and security: isolate permissions across model calls, code execution, and data storage.

    If a team lacks a full platform for now, it can start with local scripts plus temporary directories, but it must retain task versions, acceptance commands, raw logs, and result reports; otherwise, reproduction and comparison later become very hard.

    6.6 Use evaluation results in daily R&D

    It is recommended to continuously track pass rate, average latency, and average cost on your own evaluation set, and combine them with code review, static checks, and unit-test gates. The value of a coding agent is to amplify R&D efficiency, but quality responsibility still rests with the engineering team. Understanding the relationships between metrics is what turns a “smarter” model into “more reliable” delivery.