compassRouter

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

  1. Create router and specialist agents

  2. Build pipeline with switch for conditional routing

  3. Process requests

Full implementation: See router/main.py for complete code with State definition and step configuration.

AgentComponent: See the Agent as Componentarrow-up-right 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 Cookbookarrow-up-right:

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 default parameter in switch() 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)

Last updated

Was this helpful?