lesson 3 of 6 · routing — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the worklesson 3 of 6 · routing — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the worklesson 3 of 6 · routing — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the worklesson 3 of 6 · routing — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the worklesson 3 of 6 · routing — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the worklesson 3 of 6 · routing — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the worklesson 3 of 6 · routing — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the worklesson 3 of 6 · routing — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the worklesson 3 of 6 · routing — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the worklesson 3 of 6 · routing — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the worklesson 3 of 6 · routing — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the workrouting — pick the path before doing the work
Checkpoint
One last thing before we move on. pass this to mark the lesson done, or skip and keep moving. hop to the next when you're ready.
Final drill. Build a routing layer that wraps the agent loop you
already know. Write run_router(question) that:
- Calls
fake_classifier(question)and normalizes the output (.strip().lower()). - Looks up the normalized category in
SPECIALISTS. If missing, fall back to"general". - Calls the specialist function with
question. Each specialist returns a dict shaped like{"answer": "...", "tools_used": N}. - Returns a single dict:
{"category": <normalized category used>, "answer": <specialist's answer>, "tools_used": <specialist's count>}.
Note: the category used is what you actually dispatched to —
that's "general" when the classifier produced something unknown,
not the raw classifier string.
The script runs four cases. Expected output:
category=billing tools=1 answer=refunded
category=technical tools=2 answer=restarted
category=general tools=0 answer=hours: 9-5
category=general tools=0 answer=fallback answer