n4nAI

Multi-agent orchestration costs: more agents, more tokens

Practical analysis of multi-agent orchestration cost: why token usage grows nonlinearly with agents, and patterns to keep spend under control.

n4n Team5 min read1,083 words

Audio narration

Coming soon — every post will get a voice note here.

The dominant misconception about multi-agent orchestration cost is that it scales linearly with the number of agents you spin up. In practice, token spend grows superlinearly because every agent carries its own context, and the messages passed between them duplicate payloads that were already paid for once. If you are building orchestration layers on top of LLM APIs, you need to model the token graph, not the agent count.

The linear assumption breaks immediately

Engineers often budget by multiplying expected calls per agent by average tokens per call. That math ignores the fan-out of context. A single-agent prompt might be 1,500 tokens. Add a second agent that needs the same background plus the first agent’s output, and you have paid for that background twice.

Suppose you deploy five agents in a pipeline: a classifier, a retriever, a synthesizer, a critic, and a formatter. Each receives the original 1,000-token request. The classifier adds 200 tokens of output. The retriever gets the request plus classification (1,200 in). Its 800-token response goes to the synthesizer alongside the request and classification (3,000 in). The critic then ingests the synthesizer’s 1,500-token draft plus everything before it (4,500 in). The formatter takes the criticized draft plus the original request (3,200 in). Summed inputs: 1,000 + 1,200 + 3,000 + 4,500 + 3,200 = 11,900 tokens, against a naive estimate of 5 × 1,000 = 5,000. The multi-agent orchestration cost is already 2.4× the lazy math before any output tokens are generated.

Token flow in common topologies

How agents connect determines the exponent on your bill.

Chain topology

Agents pass output forward. Cost is sum of (agent_i context + cumulative prior outputs). Linear in agent count but with a growing term per step.

Star topology

A coordinator fans out to workers and collects results. If the coordinator forwards the full worker transcript to each subsequent worker, you get duplication at the hub.

Mesh topology

Every agent reads every other agent’s messages. With n agents each posting m-token messages, total ingested tokens approach n²·m. A 6-agent mesh with 500-token messages costs ~18,000 tokens just in message reads. The multi-agent orchestration cost of mesh designs is the fastest way to blow a budget without improving outcomes.

# mesh broadcast: each agent sees all others' last message
for agent in agents:
    ctx = [system[agent]] + [last_msg[a] for a in agents if a != agent]
    # ctx size grows with (n-1)*m
    complete(agent.model, ctx)

Where tokens accumulate

Context duplication

Most orchestrators pass the full conversation transcript to each agent on every turn. This is the easiest code to write and the most expensive to run.

def run_agent(agent, messages):
    # messages includes system, user, and all prior agent outputs
    return client.chat.completions.create(
        model=agent.model,
        messages=messages
    )

If messages is 4,000 tokens and you call three agents sequentially, you have ingested 12,000 input tokens before any generation.

Inter-agent chatter

Multi-agent systems frequently use negotiation or critique loops. A critic agent that reviews another agent’s output adds a full copy of that output plus its own system prompt.

critic_input = [
    {"role": "system", "content": CRITIC_PROMPT},  # 200 tokens
    {"role": "user", "content": worker_output}     # 1,200 tokens
]

Two review rounds double that cost. The multi-agent orchestration cost of a simple “generate then critique” pattern is at least 2× the single-agent baseline, often 3–4× once you include the regenerated draft.

Fallbacks and degraded providers

When a provider rate-limits, a naive retry against the same model burns more tokens on re-embedded context. Automatic fallback to a different provider saves latency but can silently switch to a pricier model if you haven’t pinned routing.

A worked example: research summarizer

Below is a minimal orchestrator that illustrates the token flow without hiding it behind a framework.

PLANNER_MODEL = "gpt-4o-mini"
RESEARCHER_MODEL = "gpt-4o"
WRITER_MODEL = "gpt-4o"

def orchestrate(query):
    plan = complete(PLANNER_MODEL, [{"role":"user","content":f"Plan: {query}"}])
    research = complete(RESEARCHER_MODEL, [
        {"role":"system","content":"You research plans."},
        {"role":"user","content":query},
        {"role":"assistant","content":plan},
        {"role":"user","content":"Execute the plan."}
    ])
    draft = complete(WRITER_MODEL, [
        {"role":"system","content":"You write from research."},
        {"role":"user","content":query},
        {"role":"assistant","content":plan},
        {"role":"user","content":research}
    ])
    return draft

Assume query is 200 tokens, plan 300, research 1,500. Input tokens: planner 200; researcher 200 (system ~50) + 200 (query) + 300 (plan) + 10 (execute) ≈ 760; writer 50 (system) + 200 + 300 + 1,500 ≈ 2,050. Total input ~3,010. Output tokens: 300 + 1,500 + 800 = 2,600. A single agent given the query and asked to produce the final draft might use 200 input + 800 output. The multi-agent orchestration cost here is roughly 5,600 total tokens vs 1,000 — a 5.6× premium for modularity.

If you run the researcher and a separate fact-checker in parallel, add another 1,500 input / 400 output. The token graph grows, but wall-clock drops.

When the premium is justified

More agents buy you three things: latency reduction via parallel branches, specialization that improves correctness, and isolation of failure domains. If the researcher and a fact-checker run in parallel, wall-clock time drops even though token count rises. For customer-facing latency, that trade is often worth it.

Specialization also lets you use a cheap model for the planner (4o-mini) and reserve expensive models for generation. The token count still climbs, but the average price per token falls. That nuance is missing from most cost panic. A 5× token increase on a 10× cheaper model is a net win.

However, adding agents to “improve reasoning” without measuring output quality is how teams quietly 10× their bill. Run an A/B: single agent with a strong prompt vs multi-agent, on a fixed eval set. If the multi-agent score is not materially better, ship the single agent.

Patterns to keep spend sane

Pass only what each agent needs

Trim the message list. The writer does not need the planner’s raw chain-of-thought, just the finalized plan.

writer_ctx = [system, {"role":"user","content":query}, {"role":"user","content":compressed_research}]

Use a token budget enforcer

Wrap calls with a guard that estimates context size and refuses to append if over budget.

MAX_CTX = 6000
def guarded_complete(model, messages):
    if estimate_tokens(messages) > MAX_CTX:
        messages = truncate(messages)
    return complete(model, messages)

Cache shared context

If the gateway forwards provider cache-control hints, mark static system prompts and knowledge bases as cached. Repeated agent calls then hit cache instead of rebilling the same tokens.

{
  "messages": [
    {"role": "system", "content": "STATIC_KB", "cache_control": {"type": "ephemeral"}}
  ]
}

Route through a metered gateway

A gateway that exposes per-token usage metering and honors client routing directives lets you cap spend per agent and swap models on degradation. n4n.ai provides that shape: one OpenAI-compatible endpoint across 240+ models with automatic fallback and per-token metering, so you can enforce a planner→mini, worker→frontier split without custom retry code.

Estimating before you build

Write a ten-line estimator before writing the orchestrator. It forces you to confront duplication.

def estimate_graph(agents, base_ctx, msg_sizes):
    total = 0
    cumulative = base_ctx
    for i, m in enumerate(msg_sizes):
        # agent i ingests base + all prior outputs
        total += agents[i]['system'] + cumulative
        cumulative += m
    return total

# chain of 4 agents, base 500, outputs [300,800,1200,600]
print(estimate_graph([{}]*4, 500, [300,800,1200,600]))

This prints 500 + (500+300) + (500+300+800) + (500+300+800+1200) = 500+800+1600+2800 = 5700 input tokens, excluding outputs. The exercise alone shifts design toward pruning.

The decisive takeaway

Default to the smallest agent graph that meets the latency and quality bar. Measure multi-agent orchestration cost as token graph area, not agent count. Add an agent only when its marginal tokens buy a real reduction in latency or a step-change in output quality that a single well-prompted call cannot achieve. Instrument every call with token counts, set hard budgets, and use caching and model tiering before you accept the superlinear tax as inevitable.

If you treat agents as cheap microservices, you will get microservice-scale bills. Treat each agent as a token-hungry process that bills by the kilobyte, and architect accordingly.

Tagsmulti-agent-orchestrationpricingtokens

Written by

n4n Team

The team building n4n — a single OpenAI-compatible API in front of 240+ models, with automatic fallback, load balancing and pay-per-token metering.

More from n4n Team →

All multi-agent orchestration patterns posts →