Wandering Giants Compute · Learn
Guide

How to Build Infrastructure for Multi-Agent AI Systems

The short answer

Multi-agent infrastructure is a shared model layer (one endpoint serving every role, optionally with a LoRA adapter per role), a queue or message bus between agents, shared state outside any one agent, a sandbox per code-running agent, one trace ID across the task tree, and a budget enforced on the whole tree.

Most common pattern
Orchestrator plus parallel worker agents
Token multiplier
Several times a single agent; Anthropic reported ~15× chat for its research system
Shared model serving
One vLLM endpoint, many roles, prefix caching
Per-role specialisation
LoRA adapters via vLLM --lora-modules
Budget scope
Whole task tree, not each agent
Workhorse GPU
H100 80 GB, $4.99/hr

A single agent with good tools solves a surprising number of problems. Multi-agent systems earn their place when work splits into parallel pieces, or when a fresh pair of eyes, a reviewer that hasn't seen the author's reasoning, makes results better. They also multiply tokens, failure modes and the difficulty of answering "what happened?". This guide covers the infrastructure that makes several cooperating agents manageable: model serving, communication, state, isolation, tracing and budgets.

What is multi-agent infrastructure?

Multi-agent infrastructure is the shared foundation that lets several AI agents, each with its own role, context and tools, work on one task without stepping on each other or blowing the budget. It extends single-agent infrastructure in four ways: one model layer serving many roles, a channel for agents to hand off work, state that lives outside any one agent, and controls (tracing and budgets) that span the whole tree of agents.

Everything in the AI agent infrastructure guide still applies. What changes is that each layer now has many clients with different needs at once.

Which multi-agent patterns are worth building?

Four patterns cover nearly every production system. The infrastructure they need differs, so choose the pattern first.

PatternHow it worksGood forInfrastructure it stresses
Orchestrator–workersA lead agent splits the task, dispatches workers in parallel, merges resultsResearch, bulk analysis, multi-file code changesModel throughput, concurrency, budget
PipelineFixed sequence of specialist agents (extract → check → write)Document processing, content workflowsQueues between stages, retries per stage
Author–reviewerOne agent produces, another critiques with a clean contextCode, reports, anything with a quality barContext isolation, loop limits
Handoff / routerA triage agent routes to a specialist that takes overSupport, sales, internal help desksShared conversation state, permissions per role

Swarms of agents freely messaging each other make good demos and hard production systems. Start with orchestrator–workers or a pipeline; both have a clear owner for every step.

A useful test before adding an agent: could this role be a tool instead? A "date parser agent" or a "currency converter agent" is a function wearing a costume. Each extra agent adds a context window to pay for, a prompt to maintain and a new way to fail. Add agents where a separate context genuinely helps (parallel research, independent review) and use plain tools everywhere else.

How should multiple agents share a model?

Serve every role from one model endpoint and differentiate roles with system prompts, tool sets and, where it helps, LoRA adapters. Separate models per agent waste GPU memory and lose the biggest efficiency available: shared batching and a shared prefix cache.

On one GPU running vLLM, ten agents hitting the same endpoint are batched together, so aggregate throughput is far higher than ten single streams. If roles share a long common prefix (a company context block, a tool catalogue), prefix caching means that prefix is computed once.

When one role needs specialisation (a SQL writer fine-tuned on your schema, a reviewer tuned on your style guide), train a LoRA adapter and serve it on the same base:

bash
vllm serve meta-llama/Llama-3.3-70B-Instruct \
  --quantization fp8 \
  --max-model-len 32768 \
  --enable-lora \
  --max-lora-rank 64 \
  --lora-modules sql-writer=/adapters/sql-writer reviewer=/adapters/reviewer \
  --enable-auto-tool-choice --tool-call-parser llama3_json \
  --api-key "$VLLM_API_KEY"

Agents then select a role by model name: model="sql-writer" uses the adapter, model="meta-llama/Llama-3.3-70B-Instruct" uses the base. The weights are about 70 GB at FP8, so on an 80 GB H100 KV cache space is tight; this layout suits a 96 GB RTX PRO 6000 or a 141 GB H200 better if many agents run concurrently. See the vLLM LoRA documentation for the flags in your version.

The common hybrid: routine roles on the private endpoint, and one "hard problems" role routed to a frontier hosted API. Because both are OpenAI-compatible, the router is a dictionary from role to base URL and model name.

How do agents communicate and share state?

Agents should communicate through the orchestrator or through durable shared state, never only through each other's context windows. Context is expensive, lossy and gone when a process dies; a database row is cheap and permanent.

Three mechanisms, in order of how often you need them:

  1. Function return values. The orchestrator calls a sub-agent like a function and gets back a short structured report. Simple and traceable. Ask sub-agents for concise reports: the orchestrator pays to read every word.
  2. A task board in the database. Agents claim, update and complete rows in a tasks table. This survives crashes, lets you see progress, and supports pipelines where stages run on different workers.
  3. A queue between stages. Redis, RabbitMQ or a cloud queue carry work from one stage's workers to the next. Use this when stages scale differently, such as one planner feeding fifty extractors.

Large artefacts (files, datasets, page captures) go to object storage, and agents pass references. Which of these stores should be long-lived and which should be thrown away with the task is covered in persistent vs ephemeral agent environments. Passing a 40,000-token document from agent to agent through prompts costs 40,000 tokens every time it moves.

What does an orchestrator look like in code?

An orchestrator fans out sub-agents concurrently, caps parallelism and enforces one budget across all of them. This minimal Python version uses the async OpenAI client against any compatible endpoint:

python
import asyncio
import os

from openai import AsyncOpenAI

client = AsyncOpenAI(base_url=os.environ["LLM_BASE_URL"], api_key=os.environ["LLM_API_KEY"])
MODEL = os.environ["LLM_MODEL"]

class Budget:
    def __init__(self, max_tokens: int):
        self.max_tokens, self.used = max_tokens, 0
    def charge(self, n: int):
        self.used += n
        if self.used > self.max_tokens:
            raise RuntimeError(f"task budget exceeded: {self.used} tokens")

async def sub_agent(topic: str, budget: Budget, sem: asyncio.Semaphore, trace_id: str) -> str:
    async with sem:
        resp = await client.chat.completions.create(
            model=MODEL,
            messages=[
                {"role": "system", "content": "Research the topic. Reply in at most 150 words."},
                {"role": "user", "content": topic},
            ],
            extra_headers={"X-Trace-Id": trace_id},
        )
        budget.charge(resp.usage.total_tokens)
        return f"## {topic}\n{resp.choices[0].message.content}"

async def orchestrate(question: str, topics: list[str]) -> str:
    budget, sem, trace_id = Budget(300_000), asyncio.Semaphore(8), os.urandom(8).hex()
    reports = await asyncio.gather(*(sub_agent(t, budget, sem, trace_id) for t in topics))
    final = await client.chat.completions.create(
        model=MODEL,
        messages=[
            {"role": "system", "content": "Combine the reports into one answer with sources of disagreement noted."},
            {"role": "user", "content": question + "\n\n" + "\n\n".join(reports)},
        ],
    )
    budget.charge(final.usage.total_tokens)
    return final.choices[0].message.content

if __name__ == "__main__":
    print(asyncio.run(orchestrate(
        "Which European countries have the most data-centre capacity planned?",
        ["Norway data centres", "Sweden data centres", "Netherlands data centres", "France data centres"],
    )))

The semaphore stops a planner that spawns 200 sub-tasks from flooding the model server; the shared Budget stops the tree, not just one branch, from overspending; and the trace ID ties every call to one task. Real sub-agents would each run their own tool loop, as in the tutorial on running agents in the cloud, but the shape stays the same.

How do you isolate agents that run code?

Give every agent that executes code its own sandbox, even if the agents belong to the same task. A shared filesystem between a coding agent and a reviewer agent lets one agent's mistakes, or a prompt injection it picked up, silently change the other's inputs.

Share data deliberately instead: the author agent writes its output to object storage, and the reviewer gets a fresh sandbox with a read-only copy. Agents that don't execute code (planners, routers, reviewers of text) need no sandbox at all, which keeps the number of live environments well below the number of agents. The agent sandbox guide covers isolation choices.

Permissions follow the same rule: give each role the smallest tool set it needs. The router doesn't need the shell; the researcher doesn't need the email tool.

How much more do multi-agent systems cost?

Multi-agent systems cost several times a single agent for the same task, because each agent builds its own context and the orchestrator re-reads all their reports. Anthropic's engineering write-up on its multi-agent research system reported roughly 15 times the tokens of a chat interaction, and a few times a single agent; it judged the trade worth it for broad research questions, not for everything.

A worked example (token counts are assumptions for illustration):

DesignCallsInput tokensOutput tokens
Single agent, 15 steps, 10k average prompt15150,0006,000
Orchestrator (4 calls, 12k average)448,0003,000
6 workers × 8 steps, 8k average prompt48384,00014,400
Multi-agent total52432,00017,400
Ratio, multi ÷ single2.9×2.9×

On a hosted API that ratio is the cost ratio. On your own GPU it is a GPU-time ratio, softened by prefix caching (workers share a system prompt) and by batching (six workers in parallel use the GPU far better than one agent stepping alone). How much concurrency a single GPU absorbs before you need a second one is worked through in scaling AI agents from one user to thousands. This is the strongest argument for a private model under multi-agent systems: parallel fan-out is exactly the load a batched GPU serves efficiently. With one H100 serving the agents, the cost of a task is the GPU-seconds it consumes × about $0.0014 per GPU-second (the hourly $4.99/hr spread over 3,600 seconds), and fan-out raises GPU utilisation rather than the price per token.

How do you observe a multi-agent system?

Trace the tree. Create one trace ID per top-level task and pass it to every sub-agent, tool call and model request; record each as a span with its parent. OpenTelemetry provides the model, and LLM tracing tools such as Langfuse, LangSmith and Arize Phoenix render agent trees directly.

Per task, record:

  • Tokens and cost per branch, so you can see which role is expensive.
  • Wall-clock time per branch, so you can see which one is the bottleneck.
  • Why each agent stopped: finished, step limit, budget, error.
  • The orchestrator's final decision and which sub-agent reports it used.

Two failure modes are specific to multi-agent systems and only visible in traces: ping-pong loops, where author and reviewer bounce a draft forever (cap revision rounds at two or three), and runaway fan-out, where a planner spawns far more workers than the task needs (cap workers per task).

When does a Wandering Giants GPU fit a multi-agent system?

It fits the shared model layer. An API GPU on Wandering Giants Compute gives all your agent roles one private OpenAI-compatible endpoint with your own key, and the batched serving underneath makes parallel fan-out efficient. A Root machine fits when you want to run vLLM yourself with your own LoRA adapters per role, or give a code-running agent a whole computer. Machines take 1, 2, 4 or 8 of the same GPU, which is enough for most multi-agent systems; we don't offer multi-node clusters or autoscaling.

Wandering Giants also designs multi-agent systems for businesses; the first recommendation is often fewer agents than planned. For alternatives at the GPU layer, see the GPU cloud providers for AI agents comparison, or our GPUs and prices.

Frequently asked questions

Do multi-agent systems need a separate model per agent?

Rarely. Most multi-agent systems run every role on one model with different system prompts and tools. When a role benefits from specialisation, a LoRA adapter on the same base model is cheaper than a second model, because one GPU can serve the base and many adapters.

Why do multi-agent systems cost so much more?

Each agent carries its own context, and the orchestrator re-reads every sub-agent's report. Parallel agents also explore overlapping ground. The result is several times the tokens of one agent for the same task; Anthropic's write-up on its multi-agent research system reported about 15 times the tokens of a chat interaction.

How do agents communicate with each other?

Usually through the orchestrator: it dispatches tasks and reads results, and sub-agents never talk directly. For looser systems, agents post messages to a queue or a shared task board in a database. Direct agent-to-agent chat is the hardest pattern to debug and is best avoided until you need it.

How do you debug a multi-agent system?

Give the top-level task one trace ID, pass it to every sub-agent, and record each agent's calls as child spans. Then you can see the whole tree of who called whom, with tokens and cost per branch. Without that, multi-agent failures are close to impossible to explain.

When is a multi-agent system worth it?

When the task splits into independent pieces that can run in parallel, such as researching ten companies, or when separate contexts genuinely help, such as a reviewer that has not seen the author's reasoning. If the work is sequential, one agent with good tools is cheaper and easier to run.

Wandering Giants Compute

Rent the GPU for this, by the minute.

Serve every agent role from one private model: launch an H100 with gpt-oss 120B or Llama 3.3 70B behind your own OpenAI-compatible key.

Prepaid credit, billed by the minute, stops itself when credit runs out. Prices in £, $, €, ¥, CA$, A$, CHF and S$; UK prices include VAT.

Keep reading

About this article. Written by the Wandering Giants Compute team, the people who run Wandering Giants Compute. Hardware figures are the manufacturers’ published specifications. Speeds and costs marked as estimates are worked out from those specifications and our current prices, with the method shown; they are not measured benchmarks. Wandering Giants prices are taken live from our price list each time this page is built.

Last reviewed 25 November 2026.