# Multi-agent systems

Compose agents with supervisor/sub-agent handoffs, planner/worker fan-out and critic reflection loops, all as visible nodes on the canvas.

Source: https://glamorous-boar.cloudvent.net/multi-agent/

---

AgenticMind has no hidden "crew" abstraction. Multi-agent patterns are composed from ordinary nodes, so every agent, handoff and loop is visible on the canvas and in the trace.

<Figure source="/src/assets/images/screens/plan.jpg" alt="A plan-and-execute multi-agent workflow after a run" caption="Plan and execute: a planner splits the goal, worker agents run in a loop, and a synthesizer writes the answer."/>

## Pattern 1: Supervisor and sub-agents

A **Subagent** node offers an agent (its own instructions, model, tools and limits) **as a tool**. A supervisor Agent delegates by calling it with `{task, context}`.

Template *Research team*:

<Diagram caption="The supervisor decides whom to delegate to; each specialist has its own tools.">

```
flowchart LR
  Q[question] --> S[Supervisor Agent]
  R[Subagent: researcher] -- tool --> S
  A[Subagent: analyst] -- tool --> S
  W[Web Fetch: wikipedia.org] -- tool --> R
  C[Calculator] -- tool --> A
  D[Date & Time] -- tool --> A
  S --> O[answer]
```

</Diagram>

- Each handoff is an explicit, traced tool call (`handoff` / `handoff_result` events; inner events labelled `supervisor > researcher`).
- Depth is capped at 3 agents, and self-delegation is refused.
- A sub-agent failure returns to the supervisor as a tool error.
- The sub-agent's tokens and cost count toward the supervisor's budget.
- Sub-agents default to `on_limit: return_partial`, so they hand back partial work with a stop reason.
- If a sub-agent's tools all failed permanently, the supervisor is told instantly that it cannot help in this run (no re-delegation loops).

Tip: write each Subagent's `description` as a job description (*A research specialist. Give it one clear task…*); that is what the supervisor reads.

## Pattern 2: Planner and workers

Template *Plan and execute*:

1. **Planner** turns the goal into at most `max_tasks` self-contained tasks via a forced `submit_plan` call. Each task must make sense on its own, because a worker sees only its task.
2. **Loop** (`for_each`, `concurrency` > 1) runs a worker **Agent** per task, in parallel.
3. **Loop End** collects the findings in task order.
4. A **synthesizer** Agent (or LLM) combines them into the answer.

This is the classic *orchestrator-workers* pattern: cheap parallelism for research and analysis.

## Pattern 3: Critic and reflection loop

Template *Write with a critic*:

1. **Loop** in `repeat` mode (`max_iterations` 3).
2. A **Writer** LLM drafts, reading the previous revision request from the loop `state`.
3. A **Critic** checks the draft:
   - **rule checks** (deterministic): `min_words`, `max_words`, `must_include`, `must_not_include`;
   - **criteria** judged by a model (e.g. *accurate*, *friendly tone*).
   It reports both separately and passes only if all rules and required criteria pass. Outputs: `passed`, `needs_revision`, `feedback`, `revision_request`, `report`; branches `pass` / `fail`.
4. **Loop End** gets `value` = the draft, `continue` = `needs_revision`, `next_state` = `revision_request`.

The loop stops as soon as the critic passes, or after 3 rounds.

## Pattern 4: Routing to specialists

A **Router** or **Classifier** picks a branch, each branch has its own agent or LLM, and a **Join** gathers the reply. Template *Ticket triage* shows the structure; swap the Text Templates for agents.

## Choosing a pattern

| Need | Pattern |
|---|---|
| Open-ended tasks needing different skills | Supervisor + sub-agents |
| A big task that splits into independent parts | Planner + workers |
| Quality bar the first draft rarely meets | Critic loop |
| Known categories of requests | Router/Classifier + specialists |
| One hard question | Not multi-agent: try the [Reasoning](/reasoning/) node |

Every extra agent costs model turns (each delegation costs at least two sub-agent turns plus a supervisor turn). Start with one agent and add structure when the trace shows why.

## Theory

[Multi-agent systems](/learn/multi-agent-systems/) in the handbook covers these patterns, debate, mixture of agents, and when multiple agents actually help.
