Multi-agent hand-off
A triage agent answers first, then hands the conversation to an expert, using chain routing.
This example: a payments support line. A fast triage agent sorts out what went wrong, then a payments expert takes over and resolves it.
Example (replies vary)
You: A payment has been stuck as pending for two days.
→ triage: "Issue: stuck payment. Status: pending 48h.
Likely cause: bank verification hold."
→ payments_expert: picks up the triage notes and answers
Agent: Payments pending for more than 24 hours are usually held for
bank verification. Here's what to do:
1. Check your bank app for a verification request.
2. ...
handoff_path: ["triage", "payments_expert"]
- Python
- TypeScript
from custodian_labs import Custodian, CustodianSquad
squad = CustodianSquad(
custodians=[
Custodian(
name="triage",
model="gpt-6-luna",
system_prompt="Classify the payment issue and summarize the key facts for the expert.",
topics=["billing", "support", "payment"],
can_handoff_to=["payments_expert"],
),
Custodian(
name="payments_expert",
model="gpt-6-luna",
system_prompt="Using the triage notes, resolve the payment issue step by step.",
),
],
routing_mode="chain",
max_handoffs=3,
)
reply = squad.deploy().chat("A payment has been stuck as pending for two days.")
print(reply.handoff_path) # ['triage', 'payments_expert']
print(reply.response)
import { Agent, AgentTeam } from "@custodianlabs/sdk";
const team = new AgentTeam({
agents: [
new Agent({
name: "triage",
model: "gpt-6-luna",
systemPrompt: "Classify the payment issue and summarize the key facts for the expert.",
topics: ["billing", "support", "payment"],
canHandoffTo: ["payments_expert"],
}),
new Agent({
name: "payments_expert",
model: "gpt-6-luna",
systemPrompt: "Using the triage notes, resolve the payment issue step by step.",
}),
],
routingMode: "chain",
maxHandoffs: 3,
});
const reply = await (await team.deploy()).chat("A payment has been stuck as pending for two days.");
console.log(reply?.handoffPath); // ["triage", "payments_expert"]
console.log(reply?.response);
Learn more
- Multi-agent routing: how hand-offs work, what the next agent sees, and
max_handoffs.