Route questions to retrieve, clarify, reformulate or abstain
Route each question to clarification, retrieval, reference lookup, bounded reformulation or abstention and compare outcomes with fixed RAG.
By Invicly Tech, , in Generative AI, Agentic AI and RAG. About 12 minutes to read.
In short
Fixed RAG runs the same retrieve-then-answer steps for every question. A routing step lets the assistant pick a better action first: ask the user to clarify, search the documents, look up a reference value, rewrite the query a limited number of times, or abstain. You only keep the router if it beats fixed RAG on the same test questions.
Think of it like this: A good help desk clerk first decides whether to ask you a question, check a binder, look up your order number or say they cannot help, instead of always reading the whole manual aloud.
Explained simply
Fixed RAG treats every question the same way. It searches the documents, puts the top results into the prompt and asks the model to answer. That works well for clear policy questions, but it wastes effort on questions that are vague, that ask for one exact value, or that the documents simply cannot answer.
A router adds one decision before the search. It looks at the question and picks a route from a short list your code defines: ask a clarifying question, search the documents, look up an exact value, rewrite the query and try again, or abstain. Abstain means politely declining and saying why.
The router can be simple rules, a small classifier or a model call that returns one of the allowed routes. Whatever picks the route, your code checks that the choice is on the list and then runs that route. The model never gets to invent a new action.
Two limits keep this safe. Query rewriting gets a small fixed number of extra tries, often one or two. And if no evidence the caller is allowed to see supports an answer, the assistant abstains instead of guessing. Finally, you test the router against fixed RAG on the same questions and keep it only if it wins.
Press Play on a diagram to walk through it one step at a time.
- Clarify
- Question is ambiguous
- Ask one short follow-up
- Retrieve documents
- Policy or how-to question
- Hybrid search with caller scope
- Reference lookup
- Exact value such as a code or limit
- Typed read-only lookup tool
- Reformulate
- First search came back weak
- Rewrite query, max 2 extra tries
- Abstain
- No permitted evidence
- Return a reason, not a guess
- 1Classify
Router returns one route from a fixed list
- 2Validate
Reject unknown routes; default to retrieve
- 3Act
Search, look up or ask the user
- 4Check evidence
Score above threshold and visible to caller?
- 5Retry or stop
Reformulate within limit, else abstain
- One search for every question
- Predictable cost and latency
- Guesses on ambiguous questions
- Simple to test and explain
- Picks clarify, retrieve, lookup or abstain
- Extra decision call per question
- Handles vague and exact-value questions better
- Needs limits and its own tests
In depth
Designing the route list
Start from the kinds of questions your fixture set contains, not from what sounds clever. For an internal knowledge assistant, five routes cover most cases. Clarify handles questions like "what is the limit?" where the user has not said which limit. Retrieve handles policy and how-to questions that need passages. Lookup handles exact facts held in structured data, such as a plan's seat limit or an office code, through a typed read-only tool. Reformulate handles a first search whose best score is under your threshold. Abstain handles questions with no permitted evidence.
Write each route as an enum value with a one-line rule for when it applies. Give the router a default for anything it cannot decide: retrieve is a safe default because the evidence check that follows will still abstain if nothing good comes back.
- Routes are an enum, not free text
- Each route has a written trigger rule
- Unknown or invalid output falls back to retrieve
- Every route ends in answer, clarify or abstain
Bounded reformulation
Reformulation means rewriting the query to find better evidence: expanding an abbreviation, adding a product name from the conversation, or splitting a two-part question. It is useful, but each try costs a model call and a search. Without a limit, a question that has no answer in the corpus can loop until the budget runs out.
Set a maximum, for example two reformulations after the first search, and make the loop count visible in the run record. Stop early when a search clears the evidence threshold. Also stop if the rewritten query is the same as one already tried after normalising case and spaces, since that search will return the same results. When the limit is reached without good evidence, the route becomes abstain with the reason no_supporting_evidence.
- 1Search
Run the current query in caller scope
- 2Score
Best hit above threshold? Exit to answer
- 3Count
Limit reached? Exit to abstain
- 4Rewrite
New query, not seen before
- Back to step 1
Clarify and abstain are real answers
Many teams treat clarification and abstention as failures because the user did not get a direct answer. In a knowledge assistant they are often the correct outcome. If a user asks about "the travel limit" and there are separate limits for domestic and international travel, guessing one gives a confident wrong answer half the time. One short question fixes that.
Abstention matters even more when permissions are involved. If the only document that answers the question belongs to a scope the caller cannot see, the assistant must not hint at its content. It returns a neutral reason such as no_supporting_evidence, the same reason it would give if the document did not exist, so the response does not reveal that hidden material exists.
- Ask at most one clarifying question per turn
- Offer the options you found, such as domestic or international
- Use the same abstain reason for missing and hidden evidence
Comparing against fixed RAG
Routing adds a decision step, which adds latency, cost and a new way to fail. It earns its place only if the overall results improve. Run fixed RAG and the routed version over the same fixture questions with the same corpus, model stub and thresholds. Record for each case the final status, whether the answer was correct, whether citations were supported, the number of model and search calls, and the time taken.
Look at the results by question type. Routing usually helps on ambiguous questions, exact-value questions and unanswerable questions, and makes little difference on clear policy questions. If it hurts clear questions, for example by sending them to clarify too often, tighten the clarify rule before deciding.
- Same questions, corpus, model and thresholds for both
- Compare by question type, not only the overall score
- Track calls and latency per case
- Keep the simpler design if results are equal
Learn it in 5 short steps
About 40m each. Track them with a timer in your plan.
- 1Define the route options~40m
- 2Ask for clarification when needed~40m
- 3Limit query reformulation steps~40m
- 4Abstain when evidence is absent~40m
- 5Compare against fixed RAG~40m
Key points
- Routes are a closed list your code defines; the model only picks one of them.
- Reformulation needs a hard limit, such as two extra searches, or it can loop forever.
- Abstaining with a clear reason is a correct outcome when no permitted evidence exists.
- Compare the router with fixed RAG on identical questions before you keep it.
- A rule-based router is a valid baseline and often handles the easy cases cheaply.
Key terms
Tap a card to flip it. 0/5 known
Examples
from enum import Enum
from pydantic import BaseModel
class Route(str, Enum):
clarify = 'clarify'
retrieve = 'retrieve'
lookup = 'lookup'
reformulate = 'reformulate'
abstain = 'abstain'
class RouteDecision(BaseModel):
route: Route
reason: str
raw = '{"route": "lookup", "reason": "asks for a plan limit"}'
decision = RouteDecision.model_validate_json(raw)The router's output is validated against a closed set of routes.
Routing three questions from the fixture set
Question A: "How many days do I have to submit an expense claim?" The router picks retrieve, the first search finds the expenses policy section with a high score, and the assistant answers with its source ID. Question B: "What is the limit?" The router picks clarify and asks whether the user means the expense, travel or seat limit. Question C: "What is the parking policy at the Lisbon office?" There is no such document. The router picks retrieve, the best score is low, two reformulations also score low, and the assistant abstains with no_supporting_evidence. Fixed RAG would have answered all three, guessing on B and C.
A small router with a safe default
This rule-based router is the baseline. It checks for exact-value patterns first, then for very short vague questions, and otherwise retrieves. A model-based router must beat it on the fixture set to replace it.
import re
LOOKUP = re.compile(r'\b(seat limit|office code|plan id)\b', re.I)
VAGUE = {'what is the limit?', 'how much?', 'when?'}
def route(question: str) -> str:
q = question.strip().lower()
if LOOKUP.search(q):
return 'lookup'
if q in VAGUE or len(q.split()) < 3:
return 'clarify'
return 'retrieve' # evidence check may still abstain
assert route('What is the seat limit on Team?') == 'lookup'
assert route('What is the limit?') == 'clarify'Quick reference
- Routes: clarify, retrieve, lookup, reformulate, abstain; a closed enum
- Invalid or unknown router output falls back to retrieve
- Cap reformulation at a small number, such as 2 extra searches
- Skip a rewritten query that matches one already tried after normalising
- Abstain with the same reason for missing and hidden evidence
- Compare routed and fixed RAG on identical questions, by question type
- A rule-based router is the baseline a model router must beat
Common mistakes
- Letting the model invent new route names and then trying to handle them.
- Reformulating without a limit, so weak queries burn budget in a loop.
- Judging the router on a few demo questions instead of the shared test set.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Write a Route enum and a Pydantic RouteDecision model, then validate the JSON {"route": "teleport"} and show that it fails.
- Exercise 2medium
Write a function retrieve_with_retries(question, search, rewrite, threshold, max_rewrites=2) that returns hits or the string 'abstain', never repeats a query and never exceeds the limit.
- Exercise 3hard
Run fixed RAG and your routed assistant over 12 fixture questions (4 clear, 4 ambiguous, 4 unanswerable) and produce a table of status, correctness and call count per question type. Decide which design to keep.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Is a router the same as an agent?
- Not quite. A router makes one choice from a fixed list and then follows a set path. An agent may make several choices in a loop. A router is often the first, safest step towards agentic behaviour.
- Should I use a model or rules to route?
- Start with rules as a baseline because they are cheap and predictable. Switch to a model only if it routes your fixture questions measurably better.
- How many reformulations are enough?
- Usually one or two. Measure how often a second or third try actually finds new evidence in your fixture set; if it rarely does, lower the limit.
- Does abstaining make the assistant look worse?
- In testing it can lower the share of answered questions, but it removes confident wrong answers, which do far more harm in an internal knowledge tool.