Router
A central agent inspects each request and routes it to the most appropriate specialist agent based on content and context.
Overview
Routers keep front-line interactions lightweight: they triage requests, choose which specialist should respond, and optionally provide fallbacks when no match is found. Common use cases include customer support triage and language translation hubs.
Demo Scenario: Language Help Desk
Four agents collaborate using gllm-pipeline with conditional routing:
Router agent – classifies the language query
Spanish expert – handles Spanish translation and explanations
Japanese expert – handles Japanese translation and explanations
General handler – provides fallback for unsupported languages
The pipeline uses the switch() step to route queries based on the router's classification, automatically directing each query to the appropriate specialist.
Diagram
Implementation Steps
Create router and specialist agents
Build pipeline with switch for conditional routing
Process requests
Full implementation: See
router/main.pyfor complete code with State definition and step configuration.AgentComponent: See the Agent as Component guide for details on the
.to_component()pattern.
How to Run
From the gl-aip/examples/multi-agent-system-patterns directory in the GL SDK Cookbook:
Set the usual environment variables in .env:
Output
Notes
This example uses gllm-pipeline with the
switch()step for conditional routing.The router agent outputs a classification label that determines which branch to execute.
Add more language specialists by adding new agents and branches to the switch.
The
defaultparameter inswitch()provides a fallback when no branch matches.To install gllm-pipeline:
uv add gllm-pipeline-binary==0.4.13(compatible with aip_agents and langgraph <0.3.x)
Related Documentation
Agents guide — Configure nested agents, memory, and streaming renderers.
Automation & scripting — Log routing results or wire the router into scheduled jobs.
Security & privacy — Apply memory and PII controls when routing sensitive requests.
Last updated
Was this helpful?