Router pattern
Words made simple
A few useful meanings before you read the explanation.
- LLM
- A model trained to work with language. It can write or summarize text, but its answer still needs checking against reliable information.
- RAG
- Find relevant information first, then give it to a model to help answer the question. The answer is only as reliable as the information and checks used.
- Agent
- An application that uses a model to choose its next action within defined limits. It can use tools and continue through several steps.
More words from this lesson
- Deterministic
- Following steps or rules defined by code. The model does not decide which step should run next in a deterministic workflow.
- Authorization
- Checking what that identity is allowed to read or do. Being logged in does not grant access to every record.
Overview
- A router chooses a specialized path based on the request.
- It can use deterministic rules, a classifier, or an LLM with a bounded enum output.
- Routing does not automatically require a full agent loop.
Why this matters
One prompt and toolset for every intent can be confusing and overprivileged.
An everyday example
Reception directs people to claims, policy support, or billing.
A technical example
claim_status → exact tool; policy_question → RAG; unclear → clarification.
How it works
- Validate request
- Classify
- Validate route enum
- Apply route-specific permissions
- Execute route.
Architecture and flow
Request → router → claim / policy / human path.
The insurance assistant example
Separate customer-data lookup from public policy explanations.
When to use it
Several clear task categories with different capabilities.
When to avoid it
A single narrow task needs no model-based router.
Interview answer
“Routing narrows the task and allowed capabilities. I use rules for obvious cases and a validated classifier for language ambiguity.”
Benefits, trade-offs, and production considerations
Routing mistakes must remain safe. Every destination rechecks authorization, and unknown categories have a clarification or escalation path.
Can you explain it without the notes?
Router pattern
Use your own words. Explain an example and one limitation before checking the explanation.
Check your explanation
A router chooses a specialized path based on the request. It can use deterministic rules, a classifier, or an LLM with a bounded enum output. Routing does not automatically require a full agent loop.
Turn this concept into a clear answer.
Practice this conceptAdapted from 13_AI.MD · “Router pattern”. Examples are study fragments; framework behavior can depend on your version.