Multi-agent · Free preview

Specialists and Handoff

Right agent for the job

A team of agents works only if each task goes to the specialist whose domain it belongs to — and to a fallback "triage" when no specialist fits.

Right agent for the job

You give one agent a giant system prompt: handle refunds, debug installs, reset passwords, answer shipping questions. It works for the easy cases, then a user asks about a failed charge and a login bug in the same breath and the agent gives a confident, half-wrong answer to both. A single generalist holds too many domains in its head at once, so each gets shallow attention and the instructions blur together.

The fix is a roster of specialists plus a router in front of them. Each specialist owns a narrow domain — billing, support, engineering — and carries only the prompt and tools that domain needs. The router's whole job is to read an incoming task and hand it off to exactly one specialist. Describe each specialist's domain with a few keywords, and routing becomes a match: does this task touch billing words (charge, refund), support words (password, login), or engineering words (install, sdk)?

Walk a case. "charge looks wrong on my card" lowercases, then you scan the roster in order: billing's keyword charge is present, so you stop and route to billing — the others never get checked. But "do you ship to Canada" touches no one's keywords. The honest move isn't to force it onto the nearest agent; it's to fall back to a triage agent that means "I don't know who owns this — figure it out." Skipping that fallback is the classic bug: an unrelated question silently lands on billing and gets a nonsense refund answer.

Routing is where multi-agent quality is won or lost. A wrong handoff wastes a whole specialist call and erodes trust; a missing triage fallback turns "unknown" into "wrong." Get the router right and every downstream agent gets clean, in-domain work.

Fill in route: lowercase the task, scan the roster in order, and return the first specialist whose keywords appear in the task. If none do, return "triage". Done looks like each task printing <task> -> <specialist>, with the Canada question landing on triage. The starter sends everything to one agent — make it actually read the task's domain.

Specialization is leverage: a good router turns a pile of generic agents into a team where every task lands on the desk that can solve it.

In the full academy, you write and run this — live, graded:

// Your specialist roster. Each agent owns a domain, described by keywords.
const specialists = [
  { name: "billing", keywords: ["charge", "refund", "card", "invoice"] },
  { name: "support", keywords: ["password", "login", "reset", "account"] },
  { name: "engineering", keywords: ["install", "sdk", "error", "bug"] },
];

// Incoming work. Each task should go to the specialist whose domain it touches.
const tasks = [
  "reset my password",
  "charge looks wrong on my card",
  "how do I install the SDK",
  "do you ship to Canada",
];

// 🧭 Route a task to the right specialist by keyword match,
// or "triage" if no specialist's keywords appear in it.
function route(task) {
  // TODO: scan the specialists and return the name of the one that fits.
  // Fall back to "triage" when none match.
  return "support";
}

for (const task of tasks) {
  console.log(`${task} -> ${route(task)}`);
}

🔒 Live code execution, real agent runs, mastery tracking and verifiable credentials unlock with the full academy.

This is 1 of 50 lessons.

The full academy: write real code, watch real agents run, and earn verifiable credentials — across 8 tracks, in a 3D campus.

Unlock the full academy — $100 →

14-day refund · 🔒 Stripe-secured checkout · lifetime access

More free lessons: An LLM Is a Function  ·  The Agent Loop  ·  Define a Tool  ·  Give an Agent a Tool  ·  Durable State

← The Agent Marketplace