Evaluating the Cost and Capability of Multi-Agent Coding

    This article examines how multi-agent coding changes both capability performance and cost structure, using a real downsampling refactoring task that consumed roughly 48 million tokens. It breaks capability evaluation into four layers, analyzes where the token budget actually goes, and outlines five practical actions for cost control, plus a reusable framework for comparing model combinations and configuration strategies by cost per accepted commit and human intervention count.

    1. Background: What a High-Consumption Coding Task Revealed

    In a recent refactoring task on a graphics library’s downsampling algorithm, a developer used a multi-agent coding workflow and handed every stage to the coding agents. The run consumed tokens in the range of 48 million, cost close to 60 RMB, and took about the length of a full dinner break. The task itself was a typical “small but hard” case: trigger re-sampling when the visual viewport changes, so that one-time downsampling no longer produces distortion in local zoom-in scenarios. All code passed tests and compiled, and the version commit was completed automatically.

    The value of this case is not the cost figure itself, but a common problem it exposes: once a coding task is handed to an agent cluster, capability performance and cost structure both shift, yet most teams evaluate only “does it run” and lack a quantitative framework.

    2. Capability Evaluation: How to Actually Measure Coding Ability

    Judging a model’s coding ability on a single dimension is always misleading. It is better to split it into at least four layers:

    1. Requirement clarification: Given a vague description, does the agent ask questions proactively and turn “tweak the downsampling” into explicit boundary conditions (viewport change threshold, caching strategy, precision tolerance)?
    2. Context retention: In a long task, does it still honor early constraints and avoid implementations that conflict with each other?
    3. Engineering closure: Does it complete compilation, testing, and committing on its own initiative, rather than only handing over code fragments?
    4. Debugging and rollback: When a test fails, can it locate the root cause instead of repeatedly making small tweaks?

    From this practice, mainstream models are already fairly mature at the engineering closure layer, completing verification and commits independently. The differences show up more in long-context consistency and in the proportion of wasted loops. The conclusion: capability evaluation should center on the number of interaction rounds required per unit of effective output, not on the impression left by a single response.

    3. Cost Breakdown: Where 48 Million Tokens Went

    High consumption usually comes from four structural overheads:

    • Repeated reading across roles: exploration, retrieval, and review roles each read the same set of files, so the same context is counted multiple times.
    • Maximum reasoning tier enabled everywhere: every role runs at the highest reasoning intensity, so even simple retrieval gets “over-thought.”
    • Failed retries and loops: repeated patching when tests fail often accounts for most of the incremental cost.
    • Long-context accumulation: the longer the session, the more historical tokens each round carries, and cost rises non-linearly.

    An illustrative budget-constraint configuration can be expressed like this:

    1. {
    2. "budget": { "max_tokens_per_task": 8000000, "max_rounds": 40 },
    3. "agents": {
    4. "planner": { "tier": "high", "max_rounds": 6 },
    5. "explore": { "tier": "low", "read_scope": "index_only" },
    6. "reviewer": { "tier": "medium", "trigger": "on_test_failure" }
    7. }
    8. }

    The key point: give different roles different reasoning tiers and round limits, and reserve high compute for the stages that genuinely need reasoning.

    4. Optimization Practice: Five Actions to Bring Cost Down

    1. Tiered configuration: use lightweight tiers for retrieval and formatting tasks; reserve high tiers for architecture design and algorithm derivation.
    2. Context trimming: feed only the file ranges relevant to the current subtask instead of putting the whole repository into context.
    3. Staged progression: produce the plan first and the code second, entering implementation only after the plan is confirmed, to reduce rework.
    4. Failure circuit breaker: after two consecutive test failures, pause and summarize the logs, then hand over to a human or a dedicated debugging role.
    5. Observability: record tokens and rounds per stage to build a cost profile, which is what makes abnormal amplification points identifiable.

    5. A Reusable Evaluation Framework

    A single table is enough to close the loop: task type, number of participating roles, total tokens, effective output (number of commits that pass tests), cost per commit, and number of human interventions. Using cost per commit and number of human interventions as the main axes for comparison lets teams evaluate the real cost-effectiveness of different model combinations and configuration strategies, rather than being swayed by parameter counts or leaderboard rankings.

    6. Conclusion

    The core lesson from this practice is that the bottleneck in AI coding has shifted from “can it write the code” to “how to deliver reliably at a controlled cost.” Capability evaluation should be layered, cost governance should be moved upstream, and configuration strategies should be differentiated. To support the execution, logging, and monitoring that long tasks like this require, you can build an observability loop with general-purpose cloud capabilities such as the container platform, log service, and monitoring and alerting offered by Baidu AI Cloud, making every token of consumption traceable and optimizable.