Skip to content

Multi-agent systems ​

Multi-agent systems let one agent delegate focused work to specialist agents. In Anvia, the simplest pattern is to expose each specialist with agent.asTool(...) and give those tools to one coordinator.

Explore multi-agent systems ​

PageLearn how to
Agent as a toolExpose a specialist agent to a coordinator.
Child eventsStream nested work without leaking private runtime data.
Memory boundariesKeep children stateless or give them an explicit session.
CoordinationMake one parent own delegation and the final answer.
Failures and limitsBound child turns and handle nested failures.
When not to useAvoid unnecessary agents and model calls.
Production checklistVerify permissions, observability, and product ownership.

The basic shape ​

text
User request
    ↓
Coordinator ──→ policy specialist
    │          technical specialist
    │          research specialist
    ↓
One final answer

The coordinator decides whether to delegate, supplies a focused task, receives each child output as a tool result, and writes the final user-facing response.

Create one specialist ​

ts
import { AgentBuilder } from '@anvia/core'

const policyAgent = new AgentBuilder('policy-review', model)
  .instructions(
    'Review the supplied draft for policy risk. Return concise findings, not a user-facing answer.',
  )
  .defaultMaxTurns(2)
  .build()

const policyReview = policyAgent.asTool({
  name: 'policy_review',
  description: 'Review a draft support answer for policy risk.',
  maxTurns: 2,
})

Add the specialist tool to the coordinator:

ts
const supportAgent = new AgentBuilder('support', model)
  .instructions(
    'Answer support questions. Use policy_review for high-risk answers, then write the final response yourself.',
  )
  .tools([policyReview, ...supportTools])
  .defaultMaxTurns(6)
  .build()

Use meaningful boundaries ​

Split out a specialist when it has a distinct role, tool set, model, output contract, or reason to be tested independently. Keep one agent when the work uses the same instructions, tools, and policy throughout.

More agents create more model calls, latency, traces, and failure modes. The boundary should make the system easier to control—not merely look more sophisticated.

Built for Anvia.