Multi-agent routing
A squad is several agents deployed behind one chat app. The person chatting sees one assistant. Behind the scenes, different agents handle different parts of the work.
Why use more than one agent?
Think of a company's front desk. One person can answer general questions, but billing questions go to accounts and technical problems go to IT. Each specialist has their own knowledge and instructions.
Splitting an assistant into specialists helps when:
- Different topics need different instructions. A billing agent should be precise and cautious. A marketing agent can be creative.
- Different topics need different files. Only the product agent needs the 200-page product manual.
- A job has distinct steps. Research first, then write.
- You want cheaper models for simple steps. A small model can sort requests while a stronger one writes the answer.
If one prompt and one set of files covers everything, a single agent is simpler. Start there.
The three routing modes
The routing mode decides which agents handle each message.
| Mode | Everyday analogy | What happens | Template |
|---|---|---|---|
single | A receptionist sending you to the right department | One agent is picked per message and answers it. | Router |
chain | A nurse who sees you first, then passes you to the doctor | The first agent answers, then passes the conversation along. | Hand-off |
workflow | An assembly line | Every agent runs, in a fixed order, building on the last one's work. | Pipeline |
single: pick the best specialist
"I was charged twice" → picks billing → billing answers
Custodian picks the agent whose keywords best match the message. It scores each agent and the highest score wins:
| Signal | Points |
|---|---|
Each of the agent's topics that appears in the message | 5 |
The agent's name appears in the message | 6 |
Each word (over 3 letters) from the agent's description that appears in the message | 1 |
The agent's priority (0 to 100) | Added as is |
If scores tie, the agent listed first wins.
Worked example. The message "I was charged twice on my invoice" contains the
billing agent's topic invoice, so billing scores 5. The product agent has no
matching words and scores 0. Billing answers.
Because matching is by keyword, pick topics your users will actually type, such as
"refund", "invoice" and "password", rather than abstract labels like "finance domain".
Put a general agent first in the list, so it answers anything that matches nothing.
chain: hand the conversation along
message → triage answers → passes to expert → expert answers
- The first agent is picked the same way as in
singlemode, and it answers. - If that agent lists another agent in
can_handoff_to, the conversation moves to the first agent listed there that hasn't spoken yet. - The next agent sees the original message plus the previous agent's answer, and writes its own.
- This repeats until an agent has no one left to hand to, or
max_handoffsis reached. The default limit is 4.
The last agent's answer is what the user sees. The reply's handoff_path lists who
took part, in order.
A hand-off happens every time an agent has a target, not only when it's unsure. Design chains where each step adds something, such as "classify the issue, then resolve it".
workflow: run every step in order
message → research → writer → final answer
- Every agent runs, in the order given by
workflow_order. - Each agent sees the original request plus the previous agent's output.
- The last agent's output is the answer the user sees.
Use it for jobs that always have the same steps: research then write, draft then edit
then translate, or gather then analyse then summarize. Every message runs every step,
so it costs more and takes longer than single.
Choosing a mode
| Ask yourself | Choose |
|---|---|
| "Does each question belong to one specialist?" | single |
| "Does one agent prepare work that another should finish?" | chain |
| "Does every request go through the same fixed steps?" | workflow |
When in doubt, start with single. It's the cheapest and fastest, because only one agent
runs per message.
Settings reference
| Setting | Mode | What it does |
|---|---|---|
topics | single, and the first pick in chain | Keywords that route messages to this agent. |
description | single, and the first pick in chain | Also used for matching, at lower weight. |
priority | single, and the first pick in chain | A head start in the score, from 0 to 100. |
can_handoff_to | chain | Which agents this one passes to. Ignored in other modes. |
max_handoffs | chain | The most hand-offs per message, from 1 to 20. |
workflow_order | workflow | The run order. Required, and every name must be an agent in the squad. |
output_key | workflow | An optional label for this step's output. |
response_schema on the squad | All | Shapes the final answer as JSON. |
Each agent in a squad is a full agent with its own model, prompt, examples, files, tools and privacy setting. Connection settings and sharing are set once for the squad.
Naming in the SDKs
| Python | TypeScript | |
|---|---|---|
| Agent | Custodian | Agent |
| Squad | CustodianSquad | AgentTeam |
| Deployed squad | CustodianSquadApp | TeamApp |
Full option lists: CustodianSquad (Python) ·
AgentTeam (TypeScript).
What the reply tells you
| Field | Meaning |
|---|---|
selected_agent | The first agent that handled the message. |
handoff_path | Every agent that ran, in order. |
contributing_agents | Every agent that contributed. |
Common questions
No. They chat with one app and get one answer. You can see who answered in the reply fields above.
No. A file attached to one agent is only searched by that agent.
Yes. All the agents share one session, so follow-up messages keep their context.