๐ฆ Routing
July 10, 2026 ยท View on GitHub
๐ Home โบ Workflows โบ ๐ฆ Routing
โ 01 Prompt Chaining โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 03 Parallelization โ
๐ฆ Routing
TL;DR: Classify an input and direct it to a specialized handler. Like a train switch โ one input takes ONE track.
Diagram
%%{init: {'theme': 'base', 'themeVariables': {'lineColor': '#64748b'}}}%%
flowchart TB
classDef user fill:#6366f1,stroke:#4f46e5,stroke-width:2px,color:#ffffff
classDef main fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#ffffff
classDef subagent fill:#ec4899,stroke:#db2777,stroke-width:2px,color:#ffffff
classDef idle fill:#94a3b8,stroke:#64748b,stroke-width:2px,color:#ffffff
INPUT["๐โโ๏ธ๐ฅ User Request"]:::user --> ROUTER{"๐๐ฆ Classify & Route"}:::main
ROUTER -.->|"Type A"| HA["๐ฆ๐ค Handler A"]:::idle
ROUTER -->|"๐๐ชบ Type B"| HB["๐ฆโก Handler B"]:::subagent
ROUTER -.->|"Type C"| HC["๐ฆ๐ค Handler C"]:::idle
ROUTER -.->|"Unknown"| DEFAULT["๐๐ค Default"]:::idle
HB -->|"๐ฆ๐ค"| FINAL["๐โโ๏ธ๐ค User Receives"]:::user
Key Insight
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ฆ ROUTING: Choose ONE branch โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ Logic: if/else, switch/case โ
โ Question: "Where should I send this?" โ
โ Result: Single output from chosen handler โ
โ โ
โ Analogy: Train switch โ One train takes ONE track โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Characteristics
| Property | Value |
|---|---|
| Complexity | Low |
| Parallelism | None |
| Human-Loop | None |
| Iteration | None |
When to Use
Routing works well for complex tasks where there are distinct categories that are better handled separately, and where classification can be handled accurately.
| Use Case | Routes |
|---|---|
| Customer support | Bug โ Tech Team, Billing โ Finance, General โ FAQ |
| Code tasks | Bug fix โ Debugger, New feature โ Builder |
| Model routing | Easy โ Claude Haiku 4.5, Hard โ Claude Sonnet 4.5 |
| Content | Question โ Q&A handler, Task โ Executor |
When NOT to Use
- All inputs require same processing
- Classification is unreliable
- Categories overlap significantly
๐ This pattern, as a file
Runnable version (offline mock, no API key ยท nika check proves the DAG before any token is spent): patterns-as-code/02-routing.nika.yaml โ see Patterns as Code.
โ 01 Prompt Chaining โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 03 Parallelization โ