Back to blog posts

11 min

What infrastructure do multi-agent AI systems need?

Learn the seven layers of multi-agent AI infrastructure, from orchestration to cost controls. See where isolated sandboxes fit and what each layer stops.

Nicolas LecomteNico is a founder of Blaxel, who usually writes about AI, agentics, and the future of AI runtimes.

Splitting work across several agents changes what the infrastructure underneath has to carry. Workers run in parallel and hand tasks to each other. Each one makes its own model and tool calls. OpenAI's Codex documentation says "subagent workflows consume more tokens than comparable single-agent runs."

More agents also run more generated code at once. When those workers share one runtime, a failure in one can reach the rest, which puts the execution layer, where agent code runs, at the center of the stack.

Every layer of a multi-agent system architecture matters, but the execution layer decides where isolation fits.

Key takeaways

  • A multi-agent stack adds seven layers around the model calls, from orchestration to cost controls.
  • Give each worker agent or task its own isolated sandbox instead of one shared container.
  • Handoff quality depends on shared state: what the next agent can read and what it can write.
  • Trace whole runs across handoffs so engineers can replay a failed run step by step.
  • Budget for token and compute multiplication, then cap turns, retries, and idle compute per agent.

What is multi-agent AI infrastructure?

Multi-agent AI infrastructure is the set of layers that lets an orchestrator and its worker agents run in production. It sits between a user request and the work several agents do. An orchestrator agent breaks the request into subtasks.

Worker agents take those subtasks, call tools, run code, and return results. If your team is new to agents built on a large language model (LLM), start with LLM agents.

A multi-agent system architecture has seven layers:

  • Orchestration
  • Execution environments
  • Shared state, memory, and files
  • Messaging and handoff protocols
  • Identity, secrets, and permissions
  • Observability and tracing
  • Cost controls and rate limits

Agents split and carry out the work, and these seven layers are what let that work run in production.

What changes when you move from one agent to many

OpenAI's agent guide recommends splitting work when an agent can't follow complicated instructions or keeps picking the wrong tools.

Adding workers to an orchestrator changes what you run and what can fail:

  • Parallel workers: Several agents run at once, each with its own model loop, tools, and code execution.
  • Handoffs: Control or context passes between agents, and anything the handoff omits is lost.
  • Shared context: Agents read, and sometimes write, the same files and state.
  • More tool calls: Per OpenAI's Codex docs, each subagent does its own model and tool work, so workflows use more tokens.
  • Compounding failure: A small upstream error becomes the input of every downstream agent.

Every added worker raises token use and gives an upstream error another place to spread. Make that trade when a single agent can't follow complicated instructions or keeps picking the wrong tools.

The seven layers of a multi-agent stack

Multi-agent AI infrastructure splits into seven layers, from orchestration through cost controls. Each one answers a separate question, such as which agent acts next or what a run may spend. Worker agents run AI-generated code, so the execution layer decides what that code can reach.

Orchestration and architecture patterns

The orchestration layer decides which agent does what, and in what order. The OpenAI Agents SDK documents two patterns. With agents as tools, a central manager calls specialists and keeps control. With handoffs, a specialist takes over the conversation, a pattern the SDK docs call decentralized.

LangGraph's langgraph-supervisor package no longer gets active maintenance. LangChain's current pattern is a supervisor agent that calls sub-agents as tools. In CrewAI's hierarchical process, a manager agent delegates tasks and validates outcomes.

The two patterns also combine: a triage agent hands off, and the specialist calls other agents as tools. LangChain's multi-agent docs explain that centralized control adds a model call, because results flow back through the main agent. Handoffs save that call but spread decisions across agents.

Check maintenance status before you commit to a framework. AutoGen is in maintenance mode, and Microsoft's AutoGen repository directs new projects to Microsoft Agent Framework. Microsoft Agent Framework reached version 1.0 on April 2, 2026. AG2, a fork of AutoGen, ships its current line as the ag2 package. For the SDK's primitives, read the OpenAI Agents SDK guide.

Execution environments for worker agents

Worker agents run AI-generated code, so the execution layer decides what that code can reach. One shared container exposes each worker's files to the others and runs every worker on one host kernel. CVE-2024-21626 showed the risk when a file descriptor leak in runc, a container runtime, let containers reach the host filesystem.

TechnologyIsolation boundaryDocumented tradeoff or result
ContainersNamespaces on a shared host kernelA host-kernel exploit can compromise containers sharing that kernel.
gVisorA per-sandbox application kernel that reimplements system calls in user spacegVisor's docs cite reduced compatibility and higher per-call overhead. A 2019 study measured simple system calls at least 2.2 times slower than in traditional containers.
Firecracker microVMsA guest kernel per microVM behind a hardware virtualization boundaryThe 2020 Firecracker paper reports boot times under 125ms and under 5MB overhead with a minimal kernel.

To reach the host, code in a microVM must first break out of its guest kernel, then the hypervisor. Even so, Firecracker's production guide says the project can't mitigate all side channels. Start each per-task sandbox from a clean base image, as MITRE ATLAS recommends.

Per-agent sandboxes, in contrast, keep a worker's state between turns. When many tasks run at once, fan-out parallel execution explains how to dispatch them. Ask each provider what guest code must cross to reach the host. Measure creation and resume latency separately at your worker count.

Shared state, memory, and files

Shared state controls what context the next agent receives at handoff. Three kinds of state coexist. Session or graph state tracks where a run stands. LangGraph checkpointers save a checkpoint at every super-step (one execution round of the graph).

OpenAI Agents SDK sessions keep history across runs. Durable files hold code and plans that outlive a session. Long-term or vector memory stores facts for later retrieval.

Concurrent writes need an explicit rule. LangGraph overwrites a key unless a reducer (a function that combines updates) merges them. Add one for any key that several nodes write. LangChain's Deep Agents docs warn that concurrent writes to one memory file can cause last-write-wins conflicts.

Cognition describes setups where multiple agents contribute intelligence while "writes stay single-threaded." Use many readers and one writer, with read-only mounts (file access that blocks edits) for readers.

Handoffs also need limits on how much context passes. In the OpenAI Agents SDK, the next agent sees the full history by default, and an input_filter reshapes it. See multi-agent file sharing for storage patterns.

Messaging and handoff protocols

Messaging is the contract between agents. Each handoff should carry a typed schema with the task, inputs, expected output, and status. Queue-based delivery lets workers finish out of order without blocking the orchestrator. Name one agent, such as the orchestrator, to decide between contradictory worker results.

Agent2Agent (A2A) handles communication between agents. Its version 1.0 release on March 12, 2026, was the first stable specification. In A2A, Agent Cards describe an agent's identity, skills, endpoint, and authentication. Messages and artifacts carry content as typed parts.

The Model Context Protocol (MCP) connects an agent to tools, data, and prompts. MCP tools represent arbitrary code execution, per its current specification, so tool calls need the same isolation as generated code. The A2A release post puts the split as "MCP inside agents, A2A between agents."

Identity, secrets, and permissions per agent

Prompt injection travels between agents. Prompt Infection research from October 2024 showed malicious prompts self-replicating across connected agents. A March 2025 paper found multi-agent systems executed arbitrary malicious code in 58 to 90% of trials with GPT-4o agents.

The rate depended on the orchestrator. The attack worked even when individual agents resisted prompt injection, because sub-agents relayed the malicious input as trusted output. The Open Worldwide Application Security Project (OWASP) lists insecure inter-agent communication as ASI07. The ASI07 guidance recommends per-agent credentials and mutual authentication.

These practices limit the spread:

  • Per-agent identity: Each agent gets its own short-lived, narrowly scoped credentials instead of a shared key.
  • Egress allowlist: Outbound calls reach only the domains the agent's task needs.
  • Proxy-based secret injection: A proxy attaches credentials to outbound calls, so agent-controlled code never holds them.
  • Human approval gates: OWASP's LLM01:2026 entry requires per-action approval when an agent combines untrusted input, sensitive data, and external actions.

Input and output checks form a separate layer of defense. Guardrails for AI agents cover them.

Observability and tracing across agents

A multi-agent trace must follow the run across every handoff. The OpenAI Agents SDK traces runs by default. It records each handoff as a span (one timed step in a trace) with source and destination agents. OpenTelemetry's generative AI conventions define invoke_agent and execute_tool spans.

Both still carry an in-development status. Propagate trace context across services to connect agents within one trace.

Root-cause analysis stays hard even with full logs. On the April 2025 Who&When benchmark, the best automated method named the responsible agent 53.5% of the time. Accuracy at naming the decisive step fell to 14.2%. Keep per-step inputs, outputs, and tool calls so an engineer can replay a failure.

Output varies between runs, so evals need per-agent scoring. The agent evaluation framework explains how.

Cost controls and rate limits

Adding workers multiplies tokens. Anthropic's June 13, 2025 engineering write-up reports agents use about four times the tokens of chat. Multi-agent systems use about 15 times as many.

Loops push costs further. A July 2026 study of infinite agentic loops traced 69.1% of findings to unbounded retries, tool iteration, and multi-agent chat. API cost exhaustion appeared in 95.6% of findings.

Two frameworks show how far default caps vary:

  • LangGraph's recursion_limit defaults to 10,007 super-steps from version 1.1.4, per the Graph API docs.
  • The OpenAI Agents SDK's run-result reference gives a max_turns default of 10. The SDK raises MaxTurnsExceeded when a run goes past that limit.

Provider rate limits apply per organization or project, so parallel workers share one quota. Anthropic's rate limits include a ramp limit that returns 429 errors after sharp usage jumps. Idle workers also accrue compute charges. For self-hosted models, the FinOps Foundation advises shutting down idle instances outside working hours.

Set a turn cap and token budget for each agent instead of relying on framework defaults.

Reference architecture for multi-agent systems

A request flows through multi-agent orchestration infrastructure in six steps:

  1. A request enters the orchestrator, which runs on trusted infrastructure with its own credentials.
  2. The orchestrator writes a plan to shared state and dispatches subtasks as typed messages.
  3. Each worker starts in its own isolated sandbox, which you create per task or resume per agent.
  4. Workers call tools over MCP and other agents over A2A, through a secret-injecting egress proxy.
  5. Workers write results to their assigned files, and the orchestrator reads and merges them.
  6. Every step emits OpenTelemetry spans to one backend, and budget checks run before each model call.

Step 1 keeps the orchestrator outside the sandbox. OpenAI's sandbox docs note that a harness (the agent's control loop) inside the sandbox shares one boundary with generated code.

LayerPurposeExample tools
OrchestrationDecompose, route, and sequence workOpenAI Agents SDK, LangGraph, CrewAI
ExecutionRun each worker's code in isolationFirecracker microVMs, gVisor
Shared stateKeep run state, files, and memoryLangGraph checkpointers, OpenAI Agents SDK sessions, shared file systems
MessagingCarry handoffs and tool callsA2A, MCP, message queues
IdentityScope credentials and outbound accessPer-agent credentials, egress allowlists, secret-injecting proxies
ObservabilityTrace runs across agentsOpenTelemetry, LangSmith, Langfuse, Arize Phoenix
Cost controlsCap turns, tokens, and idle computerecursion_limit, max_turns, provider rate limits

Common failure modes in multi-agent systems

The Multi-Agent System Failure Taxonomy (MAST) sorts 14 failure modes into system design, inter-agent misalignment, and task verification. Its October 2025 revision draws on more than 1,600 annotated traces from seven frameworks.

Failure modeWhat happensPreventing layer
Error cascadesOne agent's mistake spreads to every agent that consumes its output. OWASP lists cascading failures as ASI08.Observability: traces and validation at each handoff
Context lost at handoffThe next agent never sees earlier conversation history, a failure mode MAST lists.Messaging: typed handoff schemas
Runaway loopsAgents retry or repeat without bound, as the July 2026 loop study found.Cost controls: turn caps and recursion limits
Conflicting file writesParallel writers overwrite each other under last-write-wins.Shared state: one writer per file
Over-broad permissionsA hijacked worker uses its own credentials to act for an attacker (a confused deputy).Identity: scoped credentials and egress allowlists
Premature terminationAn agent ends the task before it meets its objectives.Orchestration: a verification step

How to move from a single agent to an orchestrator plus workers

Split work across agents only when the task calls for it. In June 2025, Anthropic's multi-agent research system outperformed single-agent Claude Opus 4 by 90.2% on an internal research eval. Anthropic adds that domains with shared context or many dependencies between agents fit poorly today.

Let evals drive the decision to add agents, as OpenAI's evaluation guide advises. Breadth-first, parallel work that mostly reads data makes the strongest case.

When evals justify the switch, add infrastructure for agent teams in this order:

  • Isolation and tracing first: Move each worker into its own sandbox and trace a full run before adding agents.
  • Shared state second: Assign one writer per artifact and define what each handoff carries.
  • Permissions third: Issue per-agent credentials, egress allowlists, and approval gates for high-impact actions.
  • Cost caps fourth: Set turn limits, token budgets, and spend alerts before traffic grows.

How Baseten Sandboxes provide the execution layer

Baseten Sandboxes cover the execution layer in this stack, with a dedicated Firecracker microVM for each sandbox. Sandbox creation takes under a second, and an idle sandbox comes back from standby in under 25ms.

The OpenAI Agents SDK supports Baseten Sandboxes as a first-class sandbox provider.

FAQs about multi-agent AI infrastructure

How do agents share context and hand off tasks?

Agents share context through run state, durable files, and long-term memory. For each handoff, define a typed message with the task, inputs, and expected output. Within one framework, such as the OpenAI Agents SDK, the framework manages handoffs. Across systems, A2A carries agent-to-agent tasks, and MCP connects agents to tools.

Should each agent run in its own sandbox?

Yes, every agent that runs AI-generated code should get its own sandbox. A shared container exposes a single kernel and filesystem to every worker. Pair sandbox isolation with an egress allowlist, because isolation doesn't restrict outbound traffic.

How much more does a multi-agent system cost to run?

Compared with chat, a multi-agent system uses about 15 times the tokens, according to Anthropic's June 2025 write-up. Unbounded retries raise the bill further. Per-agent turn caps and token budgets limit spend, and shutting down idle self-hosted instances stops their compute charges.

Related articles