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

    This article evaluates whether multi-agent coding is worth its cost and how that cost can be engineered down. Using a real refactoring task—switching a graphics library from one-time downsampling to viewport-driven dynamic resampling—it breaks capability assessment into five layers, dissects how tens of millions of tokens are consumed, and presents cost controls such as tiered routing, context trimming, parallel convergence, budget guardrails, and cache reuse. It also covers the technical design of the resampling cache and a reusable implementation checklist. Readers will learn to treat coding capability as a baseline and cost, stability, and controllability as the real differentiators.

    1. The Problem: Handing a Coding Task to a Model Cluster Instead of a Single Model

    A typical deep refactoring task looks like this: in a homegrown graphics drawing library, replace the original “downsample once” strategy with “dynamically resample as the viewport changes.” The problem with the old strategy is common—data is compressed into a fixed-precision point set on first render, and when the user later zooms into a region, the high-frequency detail that was discarded cannot be recovered, so curves become distorted.

    The difficulty here is not the amount of code but the boundaries of correctness: how to choose the downsampling threshold, how viewport changes trigger invalidation, how the cache is invalidated and rebuilt, and how to avoid crashes under extreme zoom ratios. In practice, this has led to a new paradigm: instead of assigning a single model, a group of agents with clear division of labor works together—one for reasoning and planning, one for retrieving information, one for exploring the code, and one for final review. The task runs unattended across the span of a dinner break, and the output eventually passes compilation and tests and forms a version commit automatically.

    The price is token consumption in the tens of millions and a bill in the tens of yuan. That raises the core question this article sets out to answer: is this capability worth the price, and can the cost be engineered down?

    2. Capability Assessment: Don’t Just Ask “Can It Write the Code”

    A single-dimensional “pass rate” is far from enough for evaluating a coding agent. It is better to break it into at least five layers:

    1. Requirement clarification. After the task is issued, does the model proactively ask about boundary conditions (the supported zoom range, whether peak precision must be preserved, whether the public interface may change)? Too many clarification rounds significantly raise cost; too few plant the risk of rework.
    2. Context engineering. Can it locate relevant files on its own, understand existing abstractions, and reuse utility functions already in the project rather than introducing a new style?
    3. Long-chain stability. After multiple rounds of changes, does it still maintain global consistency without regressions that “fix A and break B”?
    4. Verification loop. Does it proactively compile, run tests, read error logs, and self-correct, rather than delivering unverified code?
    5. Delivery standards. Is the change granularity reasonable, is the commit message readable, and are the necessary explanations included?

    By these five layers, today’s first-tier models have converged on small and medium refactoring, with differences showing up mainly in long-chain stability and verification initiative. A pragmatic conclusion: treat coding capability as the “pass line,” and treat cost, stability, and controllability as the “differentiators.”

    3. Cost Breakdown: How Forty Million Tokens Get Burned

    To optimize cost, first understand the consumption structure. Under a multi-agent architecture, tokens fall into roughly four categories:

    • System prompts and role definitions: each agent has its own persona and rules, and this part is billed repeatedly in every request round.
    • Context replay: conversation history and files already read accumulate linearly with each round, and in long tasks this is often the biggest item.
    • Tool-call round trips: input and output for reading files, retrieval, and executing commands—many calls, but small each time.
    • Actual output: the real code and explanations, usually the smallest share.

    A rough but useful mental model: total consumption is roughly the square of the number of rounds multiplied by the per-round context base. This means cutting ineffective rounds is more effective than compressing a single output.

    The corresponding optimizations, ranked by cost-effectiveness:

    1. 1. Tiered routing: assign low-risk actions like retrieval, exploration, and formatting to lightweight models
    2. 2. Context trimming: read only necessary fragments, archive history promptly, avoid full replay
    3. 3. Parallel convergence: run independent subtasks in parallel to reduce repeated context from serial waiting
    4. 4. Budget guardrails: set token and cost caps, trigger human intervention past a threshold
    5. 5. Cache reuse: solidify stable project conventions and interface docs into reusable context

    4. Tiered Routing: Spend the Expensive Model Where It Counts

    The most effective cost-reduction measure in practice is role tiering. Here is an illustrative configuration (field names are only illustrative; naming differs across frameworks):

    1. {
    2. "agents": {
    3. "planner": { "tier": "strong", "reasoning": "high" },
    4. "explorer": { "tier": "light" },
    5. "librarian": { "tier": "light" },
    6. "reviewer": { "tier": "strong", "reasoning": "high" },
    7. "formatter": { "tier": "light" }
    8. },
    9. "categories": {
    10. "deep": { "tier": "strong", "reasoning": "high" },
    11. "quick": { "tier": "light" },
    12. "unspecified-low": { "tier": "light" },
    13. "unspecified-high": { "tier": "strong" }
    14. }
    15. }

    Three principles apply: strong reasoning is reserved for planning and review; exploration and retrieval use the light tier; tasks without explicitly specified complexity default to the low tier, avoiding “default means expensive.” Also set a lower temperature for strong-reasoning roles to ensure consistency, and keep a higher temperature for creative roles.

    5. Dynamic Resampling: The Technical Core of the Task Itself

    Back to the algorithm being refactored. A reliable implementation usually has four parts:

    1. // Illustrative: viewport-change-driven resampling cache
    2. struct ViewportKey {
    3. double xMin, xMax, yMin, yMax;
    4. int pixelWidth;
    5. bool operator==(const ViewportKey& o) const {
    6. return pixelWidth == o.pixelWidth &&
    7. nearly_equal(xMin, o.xMin) && nearly_equal(xMax, o.xMax) &&
    8. nearly_equal(yMin, o.yMin) && nearly_equal(yMax, o.yMax);
    9. }
    10. };
    11. // Reuse on cache hit; otherwise resample at the current pixel density
    12. const Downsampled& get_series(const Series& src, const ViewportKey& key) {
    13. auto it = cache_.find(key);
    14. if (it != cache_.end()) return it->second;
    15. return cache_[key] = resample(src, key); // aggregate by on-screen pixel columns
    16. }

    Key design points: decide sampling granularity by pixel density rather than a fixed point count; use tolerance comparison on keys to avoid cache avalanches from tiny jitter; cap the number of cache entries and evict with least-recently-used; protect extreme values and the first and last points so spikes are not averaged away.

    6. A Reusable Implementation Checklist

    • Small before large: use one small task to calibrate the per-round context base and per-round time, then extrapolate the budget for a large task.
    • Enforce verification: make compilation and tests a precondition for delivery; do not generate a commit if they fail.
    • Keep stage traces: output a change summary at each stage for traceability and human takeover.
    • Cost dashboard: track tokens and cost by role to locate the real consumption hotspots.
    • Human-machine division: leave clarification and acceptance to humans, and hand retrieval and mechanical edits to the cluster.

    7. Conclusion

    Multi-agent coding is now capable enough to handle medium-scale refactoring, and its bottleneck is shifting from “can’t write it” to “too expensive and not controllable enough.” The engineering answer is not a stronger model but a three-piece kit: tiered routing, context governance, and budget guardrails. With this mechanism in place, together with general-purpose logging services and monitoring alerts in the cloud for usage observability, token consumption in the tens of millions can be compressed into an acceptable range without hurting delivery quality.