What is Introduce Router?
Introduce Router is an AI refactoring for LLM systems, in the Moving control group. Classify the input first and send it to a specialized prompt or agent.
Introduzir Roteador
Introduce Router is an AI refactoring for LLM systems, in the Moving control group. Classify the input first and send it to a specialized prompt or agent.
A single prompt or agent handles several topics, carrying the rules and tools of all of them at once. These are the Routing System Prompt, Tool Sprawl, and Mega Agent smells.
Think of a mobile carrier’s virtual assistant. It started with sales. Then it got tech support, then billing. Each topic brought a block of rules to the system prompt and a few new tools. Today, when someone asks “why is my bill higher this month?”, the model also reads the number porting rules and the instructions for restarting a modem.
The symptoms build up slowly. A billing customer gets a plan offer in the middle of an explanation. A fix to the support rules makes sales answers worse. And nobody can tell, looking at the trace, which part of the prompt the model followed.
Classify the input first, with a short step and structured output, and send each type to a specialized prompt or agent that holds only that topic’s rules and tools. The routing decision lives in code.
-SYSTEM = """You are the Carrier's assistant.
-IF sales: [800 tokens]
-IF tech support: [1,200 tokens]
-IF billing: [900 tokens]"""
-reply = agent(SYSTEM, tools=ALL_TOOLS, message=msg)
+class Route(BaseModel):
+ topic: Literal["sales", "tech", "billing", "other"]
+ confidence: float
+
+ROUTES = {
+ "sales": Agent(SALES_PROMPT, tools=[plans, offers]),
+ "tech": Agent(TECH_PROMPT, tools=[device_status, open_ticket]),
+ "billing": Agent(BILLING_PROMPT, tools=[get_invoice, explain_charge]),
+}
+
+route = llm_parse(ROUTER_PROMPT, msg, schema=Route, model="small")
+if route.topic == "other" or route.confidence < 0.7:
+ return handoff_to_human(msg)
+reply = ROUTES[route.topic].run(msg)
Before: one prompt and every tool for everything.
flowchart LR
IN(["1. Message"]):::io --> A(["2. Single prompt with three topics"]):::llm
A --> T["Every tool"]:::tool
A --> OUT(["3. Reply"]):::io
After: classification, a decision in code, and specialists.
flowchart LR
IN(["1. Message"]):::io --> R(["2. Classify topic"]):::llm
R --> D{"3. Route"}
D -->|sales| S(["4a. Sales"]):::llm
D -->|support| T(["4b. Tech support"]):::llm
D -->|billing| B(["4c. Billing"]):::llm
D -->|other| H((("4d. Human agent"))):::human
Follow a real message through both designs: “My September bill came out 40 reais higher, what is this?”
Before, the model receives about 3,000 tokens of instructions (the three blocks plus the header) and six tools. It has to figure out on its own that only the billing block matters.
After, the classifier receives a short prompt with the list of topics and a few examples, and returns this:
{ "topic": "billing", "confidence": 0.93 }
The code reads topic, sees that confidence clears the threshold, and calls the billing agent. That agent receives only the 900 billing tokens and two tools: get_invoice and explain_charge. It cannot offer a plan, because it does not even know the offers tool exists.
In the trace, the conversation gains a new field: route=billing. When an answer goes wrong, you can tell whether the classification failed or the specialist did.
A prompt with three topics forces the model to decide, on every message, which instructions apply. Sometimes it mixes them. Separating the decision (classify) from the execution (answer) turns an implicit, invisible choice into an explicit one that is recorded and testable.
Classifying is an easier task than answering. The output is one of four words, and a small model usually handles it. That is why the extra step is cheap and fast.
Each specialist stays small: only its topic’s rules and tools. That improves quality, lowers the cost per call, and lets different teams own different routes without stepping on each other. A change to the sales prompt can no longer break billing.
The target pattern is Routing. When only the tool set changes per route, and the prompt can stay the same, the target is the Tool Router. Anthropic’s “Building effective agents” post (December 2024) describes routing as one of the basic workflows, and its example is exactly customer service, with general questions, refund requests, and technical support going down different paths.
The step 2 eval is simple to build. Take a few hundred real messages, label each with the correct route, and compare against the classifier’s output. The most useful result is a confusion matrix: how many billing messages went to support, how many support messages went to sales, and so on.
The matrix shows where routes blur together. If billing and support get mixed up a lot, the boundary between them may be badly drawn, and the fix is in the list of routes, not in the prompt.
The confidence the model writes in the JSON is its guess about itself, not a calibrated probability. A model may write 0.9 for almost everything. Do not pick the 0.7 threshold by gut feeling.
Use the eval to choose. See in which confidence band the errors cluster and put the cut there. If the number does not separate hits from misses, it is useless as a threshold, and an “other” route with good examples in the prompt does more.
An internal IT agent answers questions, resets passwords, and grants access to systems. How would you split the routes, and which one needs extra care?
Three routes: questions (RAG over the IT knowledge base, no tools with side effects), password reset (a fixed flow in code, with identity verification), and access requests (an agent with a grant-access tool, always with manager approval). The access route needs extra care: it has side effects on permissions, so it goes through Human-in-the-Loop and tools with minimal scope. Low-confidence messages go to a human agent.
Notice that the password reset route does not even need a model after classification. A fixed flow is safer and more predictable than an agent for a task that always has the same steps.
Introduce Router is an AI refactoring for LLM systems, in the Moving control group. Classify the input first and send it to a specialized prompt or agent.
It treats Tool Sprawl, Routing System Prompt, and Mega Agent.
The Routing and Tool Router design pattern.