Selecting On-Device AI Coding Models: Performance, Cost, and Deployment Considerations

    This article presents a practical framework for evaluating AI coding agents in mobile development, based on a benchmark of 30 long-horizon tasks across four scenario types. It explains how to interpret key metrics—pass rate, average completion, average runtime, and cost per run—and compares high-tier versus lightweight agents. The piece offers a tiered routing strategy with budget and complexity thresholds, includes a Python routing example, and suggests cost-control measures. It is intended for engineering teams that need to choose between capability and efficiency when integrating AI agents into mobile workflows.

    What the Benchmark Covers

    AI coding agents for mobile development face stricter requirements than those for simple scripting. Projects must maintain a complete engineering structure, produce runnable UI, and meet cross-platform compatibility expectations. This benchmark defines 30 long-horizon tasks across four categories:

    • App creation: Scaffolding a project from scratch, configuring build scripts, and generating a basic UI framework.
    • Feature development: Understanding context within an existing codebase, adding new business modules, and integrating network requests or local databases.
    • Code migration: Rewriting legacy-language code into modern languages, or converting between cross-platform frameworks.
    • App transformation: Converting web or desktop business logic into mobile-native code.

    Four metrics are recorded during evaluation:

    • Pass rate: the share of tasks that compile successfully and pass all automated tests.
    • Average completion: the average proportion of code completed for tasks that did not fully pass.
    • Average runtime: the time from task start to finish.
    • Cost per benchmark run: total expenditure for completing the full evaluation suite.

    Each metric captures a different aspect. Looking only at pass rate underestimates solutions that nearly pass. Looking only at cost may lead to choosing a cheap model that cannot finish tasks.

    How to Read the Data

    In the original report, a high-tier long-horizon agent achieved a pass rate of 24.0%, average completion of 82.3%, average runtime of 27.4 hours, and a per-run cost of about $317.4. A lightweight, efficient agent achieved a pass rate of 17.3%, average completion of 71.2%, average runtime of 12.0 hours, and a per-run cost of about $9.9.

    These numbers need to be understood with limitations. The report does not fully disclose the test environment, model anonymization rules, or cost calculation methodology—for example, whether retry costs were included, or whether runtime included human correction time. They are best used as relative comparisons, not as directly reproducible conclusions. Teams doing formal model selection should rerun equivalent tasks on their own codebases.

    The gap between the two agent classes can be broken down. The high-tier model’s pass rate is about 7 percentage points higher, and its average completion is about 11 points higher. The trade-off is a runtime roughly 2.3 times longer and a cost roughly 32 times higher. The improvement in pass rate is modest, but the cost increase is large.

    Where High-Tier Agents Fit

    The higher average completion suggests that even when a task does not pass all tests, the model often produces a clear code skeleton and core logic. Based on the data, such models may be better at long-range retrieval and complex reasoning. However, the report does not reveal their internal mechanisms, so teams should verify this through their own tests.

    Typical suited scenarios include architectural design, core algorithm implementation, and deep refactoring of large legacy modules. These tasks require fewer invocations, deliver high value per run, and justify longer runtime and higher cost.

    Where Lightweight Agents Fit

    Lightweight models offer low per-run cost and short runtime, making them suitable for high-frequency calls. For teams with limited budgets or fast iteration needs, they are good at generating business module prototypes, writing unit tests, and performing routine refactoring.

    Their weakness is lower completion on complex tasks. Tasks involving multi-module coordination or deep understanding of legacy code should be delegated to higher-tier models, or broken down into smaller pieces by humans.

    How to Choose: Tiered Routing

    Teams do not have to rely on a single model. A more practical approach is to route tasks based on type, complexity, and budget:

    Task Type Complexity Budget Cap Recommended Model Acceptance Fallback on Failure
    Architecture design, legacy module refactoring High Above $300 High-tier Compilation, automated tests, manual code review Split into subtasks and rerun; if still failing, escalate to human
    Business prototypes, unit tests, routine refactoring Low to medium Within $50 Lightweight Compilation, automated tests Rerun with a balanced model
    Other tasks Medium $50 to $300 Balanced Compilation, automated tests, sample review Reduce task granularity, or escalate to human

    The complexity threshold (0.8) and budget thresholds ($300 and $50) in the table are illustrative. The report does not provide these values; teams should calibrate them against their own task histories.

    Code Example

    The following code demonstrates the basic structure of the routing logic. Model names and thresholds must be replaced with your own configuration. call_agent is a wrapper function that you implement, and it should support a cost limit parameter.

    1. from dataclasses import dataclass
    2. HEAVY_MODEL = "high-tier-agent"
    3. DEFAULT_MODEL = "balanced-agent"
    4. LIGHT_MODEL = "light-tier-agent"
    5. @dataclass
    6. class Task:
    7. description: str
    8. complexity: float # value between 0 and 1, from manual rating or rule-based scoring
    9. budget_usd: float # maximum allowed spend for this task, in USD
    10. cost_cap_usd: float # circuit breaker for a single run; if exceeded, mark for review
    11. @dataclass
    12. class AgentResult:
    13. passed: bool # compiled successfully and passed all automated tests
    14. completion: float # proportion of code completed, between 0 and 1
    15. cost_usd: float # actual cost of this run, in USD
    16. needs_review: bool # whether human review is required
    17. def pick_model(task: Task) -> str:
    18. if task.complexity > 0.8 and task.budget_usd >= 300:
    19. return HEAVY_MODEL
    20. if task.complexity <= 0.8 and task.budget_usd <= 50:
    21. return LIGHT_MODEL
    22. return DEFAULT_MODEL
    23. def run_task(task: Task, call_agent) -> AgentResult:
    24. model = pick_model(task)
    25. # Pass a cost limit so the agent stops before exceeding the budget
    26. result = call_agent(
    27. model,
    28. task.description,
    29. max_cost_usd=min(task.budget_usd, task.cost_cap_usd),
    30. )
    31. # If actual cost exceeds the circuit breaker, or if the task fails with low completion, escalate to human
    32. if result.cost_usd > task.cost_cap_usd:
    33. result.needs_review = True
    34. if not result.passed and result.completion < 0.5:
    35. result.needs_review = True
    36. return result

    Even when results pass tests, code involving permissions, payments, or data storage should be spot-checked manually. Automated tests cannot cover all security concerns.

    Cost Control

    Costs for long-horizon tasks can spiral. According to the report, a single high-tier task may take close to a day and a half, with expenses accumulating accordingly. Three measures are recommended:

    1. Set a budget cap for each task and enforce it at the call layer—do not rely only on post-hoc accounting.
    2. Automatically stop tasks that exceed a predefined time or cost limit, and notify the responsible person.
    3. Save logs of every run, track pass rates and unit costs by task type, and use real data to adjust routing decisions.