Match intent to a tool
You wrote one tool's description last lesson. Real agents carry a handful — a weather tool, a calculator, a search tool — and now the model faces a new problem: given a user message, which one? That decision is called routing, and it is the moment all those carefully-worded descriptions earn their keep.
The mechanism is simpler than it sounds. The model reads every tool's description
and judges which one's purpose overlaps most with what the user asked. You'll model
that overlap concretely: each tool advertises the keywords that describe what
it's for, and a message routes to the tool whose keywords it hits most. "Calculate
the sum of these numbers" contains calculate and sum — two hits on the
calculator, zero on weather or search — so it routes to calculator. This
keyword-scoring stands in for the model's semantic judgment; the shape of the
decision is identical.
The case that matters most is the one with no winner. "Tell me a story about a dragon" matches no tool's keywords at all — and the correct move is to call nothing and answer in plain text. Forcing a bad tool call here is a real failure mode: it wastes a round-trip, can throw an error, and erodes trust when the agent grabs a calculator to tell a bedtime story. "Call nothing" is always a valid route.
Below is a small registry of tools, each advertising its keywords, and four user
messages. Finish route so it scores every tool by how many keywords appear in
the message, returns the highest scorer's name, and falls back to "none" when
the best score is 0. Done is all four messages routing exactly as expected,
including the dragon story routing to none.
Routing is just matching intent to description. The better your tool descriptions, the better the model routes — and "call nothing" is always a valid choice.