Router
Router classifies each request and hands it to exactly one
specialist Agent. It is the cheapest multi-agent pattern (one
classifier call plus one specialist run), so use it when requests fall
into clear categories that each need a different specialist. Other
frameworks have the same shape: the OpenAI Agents SDK “handoff”
pattern, CrewAI sequential processes, LangGraph conditional edges.
Pattern
- Classify. A small fast LLM call decides which route handles
the input best. Its answer is matched to a route name ignoring
case, markdown and quotes, and treating spaces, hyphens and
underscores alike, so
**Route:** Tech Supportreachestech_support. - Dispatch. The chosen specialist
Agentruns to completion with its own model / memory / tools / architecture. - Return. The specialist’s output becomes the Router’s output. No cross-specialist synthesis.
Compared to Supervisor
- Cheaper: 1 Classification + 1 specialist; no synthesis pass.
- Deterministic: Single specialist owns the task end-to-end.
- Less flexible: No multi-domain tasks; routing errors cascade.
Usage
from loomflow import Agent
from loomflow.architecture import RouterRoute
from loomflow.team import Team
billing = Agent("Handle billing questions.", model="claude-opus-4-7", tools=[...])
tech = Agent("Handle technical questions.", model="claude-opus-4-7", tools=[...])
sales = Agent("Handle sales questions.", model="claude-opus-4-7")
team = Team.router(
routes=[
RouterRoute(name="billing", agent=billing,
description="Charges, refunds, invoicing, plan changes."),
RouterRoute(name="tech", agent=tech,
description="Errors, debugging, integration help."),
RouterRoute(name="sales", agent=sales,
description="Pricing, demos, contracts, partnerships."),
],
instructions="You are the customer support entry point.",
model="claude-haiku-4-5", # small fast classifier
)
result = await team.run("My credit card was charged twice.")
# Routed to billing.When to use
- Customer support: Route to billing / tech / sales / general.
- Coding agent gateway: Route to language-specific specialists.
- Search front-end: Route between retrieval strategies.
The classifier is the cost knob. Use a small fast model (Haiku, gpt-4o-mini) for the classifier and reserve the big model for specialists.
RouterRoute descriptions are the prompt. The classifier sees each
route’s name + description; the description is what makes routing
correct or wrong. Be specific about what each route handles AND what
it doesn’t (e.g. “Handle billing. NOT refunds, those go to support”).