Skip to main content

Overview

Multi-agent systems involve multiple agents working together to solve complex problems. While other frameworks require you to find contrived ways to have agents spawn agents, the Agentica SDK makes this trivial: pass an agentic function or an agent to another agentic function or agent. That’s it. No special orchestration layers, no graphs, no composition primitives or DSL, no message-passing protocols, no global state management. It’s just code.

When to Use Multi-Agent Systems

Multi-agent systems shine when:
  • Tasks can be parallelized: Multiple independent sub-tasks may be worked on simultaneously
  • Specialization helps: Different agents with different capabilities or contexts tackle different aspects
  • Complex workflows: The problem naturally breaks down into distinct phases or responsibilities
  • Iterative refinement: One agent’s output becomes another agent’s input

The Core Concept

Because the Agentica SDK allows you to pass any runtime value into scope — functions, objects, classes, SDKs — this naturally includes:
  • The spawn() function itself
  • Existing agents
  • Agentic functions
  • Custom orchestration logic
When you pass these to an agent or agentic function, they can use them just like anything else in scope. No schemas, no special handling. It’s just code.

Pattern: Basic Composition

Let’s start with the simplest possible multi-agent pattern: calling one agentic function from another.
This is a multi-agent system: two separate agent invocations, each specialized for its task, composed together. However the “workflow” here is very boring — it’s entirely serial, with no conditionality. Let’s take a look at what introducing control flow is like.

Pattern: External Control Flow

In this pattern, you orchestrate the agents from your code. You decide when to call agents, what tasks to give them, and how to combine their results. You write the control flow: loops, conditionals, error handling — all the logic that coordinates the agents. This is useful when:
  • The workflow involves iteration, conditionals, or complex branching
  • You want explicit control over execution order and conditions
  • You need to inject custom logic between agent calls
  • You’re building a specific, repeatable process with clear control flow

Example: Parallelization, Iteration, and Conditional Logic

Notice how you write the parallelization, the conditional branching, the iteration logic. Agents are just functions you call — the control flow is yours. This is just regular programming with agents as building blocks.

Pattern: Coordinator + Workers

Now here’s where the Agentica SDK’s design truly shines. Instead of you controlling the flow, let an agent control it. A coordinator agent manages multiple worker agents, each handling independent sub-tasks. This is useful when:
  • The number of sub-tasks isn’t known in advance
  • The workflow needs to adapt based on intermediate results
  • You want agents to decide how to parallelize work
  • Sub-tasks benefit from specialization
  • The problem is too complex for fixed orchestration logic

Most Constrained: Passing Specific Agent Objects

Let’s start with the most constrained approach: pass pre-configured agent objects with specific capabilities.
The coordinator can now invoke the specialist agents, pass data between them, and decide when to use which one — all dynamically based on the task.

Least Constrained: Passing spawn Itself

For maximum flexibility, pass spawn itself so the coordinator can create any agents it needs:
What just happened? The coordinator agent can now:
  • Decide how many sub-agents it needs
  • Spawn them dynamically using spawn()
  • Assign them specific tasks
  • Wait for their results
  • Synthesize everything into a final report
You didn’t write any of that orchestration logic. The agent figured it out.
For a richer case of this pattern, see the Deep Research example.

Best Practices

1. Choose the Right Pattern

  • Basic composition: For simple sequential agentic operations
  • External control flow: For predictable processes with iteration and conditionals
  • Coordinator + workers: For dynamic, adaptive workflows where agents orchestrate other agents

2. Be Clear About Responsibilities

Give each agent a focused premise that defines its role:

3. Use Appropriate Scope

Only pass what each agent needs:

Why This Works in the Agentica SDK

In traditional agent frameworks, multi-agent systems require:
  • Message-passing protocols
  • State management systems
  • Complex orchestration layers
  • Schema definitions for inter-agent communication
With the Agentica SDK, none of that is needed because:
  1. Everything is just scope: Agents, functions, objects — they’re all just values you can pass around
  2. Warp handles communication: The framework automatically manages calls between your runtime and the sandbox
  3. Proxies enable references: Agents can pass complex objects without serialization
  4. REPL enables agency: Agents can write actual code to orchestrate other agents, not just call predefined tools
The result: multi-agent systems that feel like regular programming, not framework wrangling.

Next Steps

Error Handling

Handle errors in multi-agent systems

Best Practices

Production-ready patterns

Human-in-the-Loop

Add human oversight to agents

Examples

See the Deep Research multi-agent example