Multi-Agent Token Cost Governance: How to Control LLM Spending in Production

    This article examines why token consumption in multi-agent coding workflows grows far faster than teams expect, breaking down the four root causes: repeated context transmission, uncontrolled task granularity, missing budget guardrails, and peak-hour contention under rate-based session limits. It then presents a five-layer cost control framework covering task tiering and scheduling, off-peak queuing, context compression and retrieval in place of full-text injection, budget enforcement with circuit breakers, and observability with unit economics. A four-stage rollout plan and closing recommendations help teams move multi-agent systems from impressive demos to predictable bills.

    1. The Problem: AI Coding Bills Are Breaking Linear Expectations

    A pattern that keeps coming up in the industry is that token consumption in multi-agent coding workflows runs far ahead of initial team estimates. Public discussion has mentioned engineers who use AI coding tools heavily inside a research organization reaching monthly costs in the six-figure USD range; founders have also reported that heavy users spend four figures in tokens per day, approaching an engineer’s annual salary on a yearly basis. At the same time, paid subscriptions on the consumer side doubled in a year, yet the large majority of new users stayed on the lowest tier.

    Put these two sets of facts together and the conclusion is not complicated: token spending is turning into something that competes with headcount cost rather than sitting on the other side of it. Once a single knowledge worker’s daily model spend starts to be compared with a salary, cost governance has to move from “review the bill after the fact” to the architecture design stage.

    The point here is not that multi-agent is bad. It is that the default cost model of multi-agent conflicts sharply with traditional software cost intuition:

    • Traditional service calls cost roughly linearly: request count multiplied by unit price, which is predictable, load-testable, and plannable for capacity.
    • Multi-agent cost is multiplicative stacking: the orchestrator and child agents exchange context repeatedly, and every round carries historical messages, tool return values, and retrieved snippets, so tokens grow roughly quadratically with the number of rounds.
    • Retries and self-correction amplify consumption further: a patch that fails tests once can trigger a multi-round “analyze, modify, re-verify” loop, and each round replays the full context.

    2. Root Causes: The Four Places the Money Actually Goes

    2.1 Repeated Context Transmission

    The most common way to implement multi-agent collaboration is a “shared conversation history.” That creates a hidden cost: the input length of round N is roughly the accumulated length of the previous N rounds. If a single round outputs O and the accumulated history is N × O, total input tokens land in the O(N²) range. This is also why adding “just one more review agent” can double the bill.

    2.2 Uncontrolled Task Granularity

    Handing “implement a feature module” to an agent as one block versus splitting it into fine-grained tasks like “read code, locate, change one spot, run tests” produces a huge difference in token consumption. The former forces the model to scan irrelevant files repeatedly inside an extremely long context; the latter loads only the necessary snippets each time.

    2.3 No Budget Guardrails

    Most teams have no notion of quota at the application layer: no limits per project, per person, or per task type, no per-task token circuit breaker, and no degradation path when a budget is exceeded. The bill can only be received passively at month end.

    2.4 Peak-Hour Contention and Elastic Rate Limiting

    The supply side is adjusting too. Some platforms have publicly stated that during demand peaks they reduce the rate at which session allowances are released for free, Pro, and Max tier users; the weekly total limit stays the same, but fewer tokens are available inside a 5-hour session window, so roughly 7% of users (mostly mid- and low-tier subscribers) hit limits they would not have hit before. The technical implication is clear: a session window is a “rate” concept, not a “total volume” concept. Running heavy background jobs during peak hours means spending the most expensive time budget on the least urgent work.

    3. Governance Framework: Five Layers of Cost Control

    Layer 1: Task Tiering and Scheduling Policy

    Classify tasks by whether they need long context, then choose the execution mode.

    1. # Example: task tiering and scheduling configuration
    2. tasks:
    3. - name: single_file_fix
    4. context: file # inject only the target file
    5. max_rounds: 2
    6. priority: low # can be shifted off-peak
    7. - name: cross_module_refactor
    8. context: repo_map # inject a repository structure summary, not the full text
    9. max_rounds: 6
    10. priority: high
    11. budget_tokens: 400000

    The key principle: align the injected context scope strictly with what the task actually needs. Do not default to “the whole repository is visible.”

    Layer 2: Off-Peak Execution and Queuing

    Put deferrable high-consumption tasks (batch refactors, full test-fix runs, documentation generation) into a queue and run them outside peak hours. In engineering terms, a message queue can smooth the peak, and elastic scaling on a container platform can concentrate compute budget release in low-traffic windows. For teams drawing on subscription allowances, this item usually delivers the most direct improvement in day-to-day experience.

    Layer 3: Context Compression and Retrieval Instead of Full Text

    • Replace full source injection with repository structure summaries and symbol indexes;
    • Structurally trim long tool return values, keeping only fields relevant to the current subgoal;
    • Adopt a communication protocol where “a child agent returns conclusions rather than the whole process,” so process logs do not accumulate at the orchestration layer.
    1. # Anti-pattern: the child agent returns all reasoning and tool output
    2. child_result = { "trace": [...everything...], "answer": "..." }
    3. # Recommended: return only verifiable conclusions and minimal evidence
    4. child_result = { "answer": "...", "evidence": ["file:line"], "confidence": 0.9 }

    Layer 4: Budget Guardrails and Circuit Breakers

    Enforce hard constraints at the orchestration layer. This is the core of turning “unpredictable” into “predictable.”

    1. class BudgetGuard:
    2. def __init__(self, task_budget, session_budget):
    3. self.task_budget = task_budget
    4. self.session_budget = session_budget
    5. self.task_used = 0
    6. self.session_used = 0
    7. def before_call(self, est_tokens):
    8. if self.task_used + est_tokens > self.task_budget:
    9. raise TaskBudgetExceeded("switch_to_cheaper_model_or_split")
    10. if self.session_used + est_tokens > self.session_budget:
    11. raise SessionBudgetExceeded("defer_to_off_peak_queue")
    12. def after_call(self, actual_tokens):
    13. self.task_used += actual_tokens
    14. self.session_used += actual_tokens

    Supporting policies include automatically degrading to a smaller-parameter model when a budget is exceeded, splitting large tasks into resumable checkpoints, and setting a maximum round limit for loops that keep failing.

    Layer 5: Observability and Unit Economics

    No measurement, no optimization. At minimum you need three categories of metrics:

    1. Token cost per task: aggregated by project, by person, and by task type;
    2. Effective output ratio: changed lines that pass tests divided by tokens consumed, used to tell whether the problem is the model or the context;
    3. Cache hit rate: whether repeated requests with the same prefix hit the cache, which is the fastest lever for cutting cost.

    You can build a dashboard on top of logging services and monitoring alerts, with threshold alerts for abnormal growth, for example triggering manual review when a single task exceeds 3× the baseline token count.

    4. Suggested Rollout Path

    Phase 1 (1 week): wire up usage instrumentation, get the real distribution, and identify the top 10% highest-consumption tasks.

    Phase 2 (2–3 weeks): ship budget guardrails and the off-peak queue, and move background tasks out of the peak window.

    Phase 3 (1 month): rework the context injection strategy, replace full text with retrieval and summaries, and establish cache reuse.

    Phase 4 (ongoing): bring cost per unit of output into R&D efficiency metrics and review it alongside delivery quality.

    5. Conclusion

    The efficiency gains from multi-agent are real, and so is the cost overrun; the two are not in conflict. What is in conflict is the gap between “default configuration” and “production-grade requirements.” When session allowances shift from volume semantics to rate semantics, and when a single engineer’s daily token spend starts to compare with headcount cost, cost governance has to become a first-class citizen of the architecture. For teams building an AI-assisted development system on a cloud platform such as Baidu AI Cloud, getting these five things solid — task tiering, off-peak scheduling, context compression, budget circuit breaking, and observability — is the key step in moving multi-agent from a “demo that impresses” to a “bill you can control.”