The Cost and Capability of Multi-Agent Coding: A Practical Evaluation

    This article examines the real cost structure of multi-agent coding and how to evaluate it. It explains why a seemingly small refactoring task can consume tens of millions of tokens, breaks coding capability into five verifiable dimensions, and identifies four amplifiers behind the token bill: repeated context injection, high-reasoning-tier overhead, exploratory loops, and role proliferation. It then outlines cost-reduction strategies such as task slicing, context governance, model tiering, budget guardrails, test-first verification, and observability, concluding that the right approach is an engineering system of tiered scheduling, budget guardrails, and test-driven validation rather than a single "strongest model."

    1. Background: Why a “Simple” Refactor Costs So Much

    In multi-agent coding practice, a common cognitive bias is equating task complexity with the amount of code changed. What actually drives resource consumption is reasoning steps × context length per step.

    Take the rework of a downsampling algorithm in a drawing library as an example. The requirement itself was a single sentence: trigger re-sampling when the visual viewport changes, so that a one-time downsample does not become distorted after local zooming. In practice, however, it spans several stages: understanding the existing sampling path, designing the trigger condition, handling boundaries and cache consistency, keeping interaction smooth, and adding regression tests.

    A developer ran this task on an intelligent coding tool configured at the highest reasoning tier. It consumed roughly 48 million tokens, cost nearly 60 RMB, and took about as long as cooking dinner. The code compiled, passed tests, and was committed automatically. This number is not unusual; it simply exposes the cost structure of a multi-agent architecture.

    2. Capability Evaluation: Breaking “Coding Ability” into Verifiable Dimensions

    To assess the coding ability of a model or an orchestration setup, avoid sweeping conclusions and break it into five dimensions:

    • Requirement clarification: Does it ask questions when information is missing instead of guessing at an implementation?
    • Long-context understanding: Can it locate the real call chain inside tens of thousands of lines of existing code, rather than superficially similar snippets?
    • Trade-off reasoning: Can it give explainable choices among accuracy, performance, and memory?
    • Engineering closure: After the change, can it compile, test, and commit, delivering a complete result?
    • Stability: Is variance low across repeated runs, without “right this time, wrong next time”?

    Under this framework, today’s first-tier models are already usable in the “clarify–implement–verify” loop and sit in the same bracket as mainstream strong models. The difference lies more in cost per task than in whether the capability exists.

    3. Where the Cost Comes From: Four Amplifiers of the Token Bill

    1. Repeated context injection: In multi-agent mode, the planning, execution, and review roles each carry their own system prompts and history, so the same code is billed over and over.
    2. Hidden overhead of high reasoning tiers: Intensive thinking modes generate large amounts of intermediate reasoning content, which also counts toward usage.
    3. Exploratory loops: Reading files, searching, trial and error, and rolling back each count as a full request.
    4. Role proliferation: The more roles there are, the more coordination overhead grows non-linearly.

    An illustrative layered configuration (not a specific product interface):

    1. {
    2. "orchestrator": { "tier": "high" },
    3. "implementer": { "tier": "high" },
    4. "explorer": { "tier": "low" },
    5. "reviewer": { "tier": "mid" }
    6. }

    There is only one principle: reserve expensive compute for decisions and implementation, and give cheap compute to retrieval and summarization.

    4. Optimization Strategies: Cutting Cost Without Sacrificing Quality

    • Task slicing: Split a large refactor into small, independently verifiable steps, converging on each before moving on, to avoid a long rolling history.
    • Context governance: Inject only relevant files and interface signatures, replacing full-text pastes with summaries.
    • Model tiering: Assign exploration, retrieval, and formatting work to lightweight tiers; leave architecture decisions and difficult debugging to high tiers.
    • Budget guardrails: Set a per-task token limit and stage checkpoints; pause and report when the limit is exceeded.
    • Verification first: Add tests before changing the implementation, so that “is it correct” is decided by tests rather than model self-assessment.
    • Observability: Record usage at each stage to pinpoint the real consumption hotspots.

    5. Conclusion

    The token bill for a high-complexity refactor is essentially a mirror of architectural choices. A multi-agent setup buys stability and closed-loop delivery at the price of context redundancy. The rational approach is not to chase a single “strongest model” but to build an engineering system of “tiered scheduling + budget guardrails + test-driven verification.” If an organization wants to deploy similar capabilities in its own environment, it can build an observable, cost-attributable intelligent coding pipeline on general cloud capabilities such as the container platform, log service, and monitoring and alerting offered by Baidu AI Cloud, so that every unit of compute is spent on the decisions that truly matter.