Module 6 — Routing to the Right Tool
Give an agent one tool and there is no decision to make. Give it a toolbox — a calculator, a population lookup, a weather service, a calendar, a search — and a new question appears on every single step: which tool fits this request? That decision is called routing, and getting it right is what separates a useful agent from one that returns nonsense. Pick the wrong tool and the observation is useless or wrong, and the whole loop goes off course.
The router matches intent to capability
A router looks at the request, considers what each available tool is for (its name and description), and dispatches to the best match. "What's 12% of 90?" is arithmetic → the calculator. "What's the weather in Paris?" → the weather tool. "What's on my calendar?" → the calendar. The agent is reading the intent of the request and matching it to a tool's stated job. More tools means more power, but also more chances to misroute — which is exactly why clear tool descriptions matter so much.
Send requests through the router
Pick a request and watch the router decide. It scores each tool against the request, picks the best, calls it, and shows the observation. Try the tricky ones — a request that looks like one tool but needs another — and watch what a good router does. You can also see what happens when it routes to the wrong tool.
This activity needs JavaScript. The lesson below still covers everything.
# each tool advertises what it is for; the router matches the request to one tools = { "calculator": "evaluate arithmetic like '12 * 0.9'", "weather": "current weather for a city", "calendar": "the user's events for today", } def route(request): # the model reads the request's intent and the tool descriptions, # then returns the name of the single best-fitting tool return best_match(request, tools)
In a real agent the router IS the language model: on each step it is shown the tool list and decides which to call. "Tool/function calling" is routing — choosing the right capability for the moment.
Check your understanding
A few questions about routing. You will get a score.
This activity needs JavaScript.