LLM-Assisted Android Development: Practical Model Selection on a Fixed Token Budget

    This article explains how to choose and orchestrate large language models for Android development when the token budget is fixed. Instead of ranking models by raw capability, it introduces effective token ratio as a practical metric and proposes a three-role workflow—planning, review, and execution—that assigns slow, deep models to offline planning and review, and fast, lightweight models to high-frequency execution. It covers a contract-document structure that keeps context lean, a checklist-driven review process, guardrails for exploratory and batch tasks, context engineering techniques, metrics for budget allocation, and common anti-patterns. The goal is more deterministic delivery quality from a limited budget.

    1. The Real Problem: On a Fixed Budget, You Are Comparing Deterministic Output per Token

    When teams introduce AI coding tools into Android application development, they often fall into a trap: comparing model capability rankings while ignoring the actual constraint, which is a fixed budget. Once the total token allowance is locked, the question shifts from “which model is stronger” to “at the same level of consumption, which one produces a higher share of effective output.” This calls for a simple metric: effective token ratio = tokens that make it into the final artifact / total tokens consumed. If thinking during the planning phase never converts into executable steps, or if the review phase only produces vague comments, this ratio drops.

    So practical selection is not a binary choice. It is about dividing roles by task type and placing models with different capability tendencies where they maximize “certainty.”

    2. Role Separation: A Three-Stage Pattern of Planning, Review, and Execution

    A pattern repeatedly validated in engineering practice is three-stage collaboration:

    • Planning role: responsible for requirement clarification, module breakdown, interface and data model drafts, and a risk list. It is judged by breadth of thinking and coverage—whether it anticipates edge cases (permissions, lifecycle, offline, weak networks, staged rollouts).
    • Review role: responsible for fault-finding on the plan and the artifacts, producing actionable change items. It is judged by the density and accuracy of issues found, not by writing style.
    • Execution role: responsible for writing code, writing tests, and large-scale repetitive refactoring. It is judged by speed and stability—delivering compilable, rollback-friendly changes within an acceptable time.

    The key insight: models with strong reasoning tendencies have a clear advantage in solution divergence, but they tend to “overthink,” repeatedly reasoning internally and delaying output, which significantly increases perceived latency in interactive development. Faster lightweight models may over-reason as well, but because their output per unit time is high, the experience feels smoother. So placing “slow and deep” models in planning and review, where offline latency is acceptable, and “fast and steady” models in high-frequency execution, is the optimal solution under a fixed budget.

    3. Why Separating Planning from Execution Improves Cost Efficiency

    Mixed work inflates context repeatedly: the execution stage keeps re-reading requirement discussions, and tokens are consumed heavily on duplicated information. After separation, the planning output is fixed as a “contract document,” and the execution stage loads only the contract and relevant code snippets—leaner and more precise context.

    Suggested contract document structure (usable directly as a prompt skeleton):

    1. ## Goal
    2. One sentence describing the value the user can perceive
    3. ## Scope
    4. Included / not included (explicit exclusions to prevent scope creep)
    5. ## Architecture Constraints
    6. - Layers: UI / domain / data
    7. - Dependency injection approach, threading model, error handling strategy
    8. ## Data and Interfaces
    9. - Entity fields and constraints
    10. - Local storage and remote sync strategy
    11. ## Acceptance Criteria
    12. - Functional cases, exception cases, performance targets
    13. ## Risks and Rollback
    14. - Compatibility risks, staged rollout plan, feature switch design

    The execution-stage prompt should be extremely constrained:

    1. Complete the task based only on the contract and code snippets below; do not expand scope.
    2. Output: 1) list of changed files 2) key diff 3) self-test steps
    3. If the contract is missing information, list questions first; do not make assumptions.

    This pipeline of “contract first, then coding, then review” makes every token serve a clear artifact, so the effective ratio naturally rises under a fixed budget.

    4. The Review Stage: Turning Fault-Finding into an Actionable Checklist

    Review most easily becomes vague. The way to improve output is to provide fixed review dimensions and require a per-item judgment with a severity level:

    1. Lifecycle and state: configuration changes, background recovery, state rebuilding after the process is killed.
    2. Concurrency and threading: main-thread blocking, coroutine scopes, cancellation and timeouts.
    3. Storage and migration: database version upgrades, field compatibility, rollback paths.
    4. Network and offline: weak-network retries, idempotency, cache consistency.
    5. Permissions and privacy: least privilege, runtime authorization, sensitive data not written to logs.
    6. Performance and resources: startup time, peak memory, list scrolling smoothness, package size.
    7. Testability: whether dependencies are replaceable, whether key paths have corresponding cases.

    Requiring review output as a four-part tuple of “issue—location—fix suggestion—verification method” significantly reduces rework.

    5. Exploratory Tasks and Batch Execution: Hand Them to the Lightweight, High-Speed Role

    Exploratory tasks (reading unfamiliar code, locating build failures, tracing call chains) and batch execution (renaming, migrating syntax, adding test skeletons) are high-frequency with low per-change risk, making them suitable for a speed-first role. To control risk, add two guardrails: first, small-step commits, where each change compiles and rolls back independently; second, have the review role spot-check the diff rather than perform a full deep review.

    6. Context Engineering: The Most Underrated Lever on a Fixed Budget

    • Prioritize precise retrieval: feed only files and symbols directly relevant to the task; avoid stuffing in the whole repository.
    • Layered context: contract layer (stable) + code layer (relevant snippets) + feedback layer (compile errors and logs).
    • Structured error feedback: organize build and test failures as “error code + location + expected/actual,” which is cheaper and more accurate than pasting entire logs.
    • Cache reuse: fix the contract and conventions as a reusable prefix to reduce repeated description.

    Example: a feedback template for a single failure fix

    1. Task: fix the following failure with minimal changes only
    2. Error: unresolved reference: XxxAdapter
    3. Location: app/src/.../HomeFragment.kt:42
    4. Expected: compile successfully and preserve existing behavior
    5. Constraints: no new dependencies, no changes to public interfaces

    7. Measurement and Tuning: Let Data Decide Budget Allocation

    Track four metrics: first-pass rate (the share needing no major manual rework), rework rounds, token consumption per task, and manual takeover time. Review weekly and shift budget toward the stage with the highest marginal return. If a higher first-pass rate in planning reduces downstream rework, the overall result is still a gain even if planning consumes more.

    8. Common Anti-Patterns

    • Having the same role both plan and execute, causing context pollution and scope creep.
    • Review that only wants conclusions and no checklist, which cannot be acted on.
    • Pursuing a single large change at the expense of rollback capability.
    • Ignoring non-functional requirements (performance, compatibility, privacy), which is extremely costly later.

    9. Conclusion

    When the token budget is fixed, practicality comes from role division and process, not from the absolute strength of a single model. Put divergence and deep analysis in planning and review, hand high-frequency implementation to the lightweight high-speed role, compress context with a contract document, control risk with checklist-driven review and rollback-friendly small-step commits, and continuously reallocate budget based on data. This approach can be implemented reliably on top of the container platform, log service, and monitoring and alerting capabilities offered by general cloud environments such as Baidu AI Cloud, so a limited budget produces more deterministic delivery quality.