Lesson 02.03 · Phase 02 · Tool Use & Function Calling
Writing a tool dispatcher
Between "the model asked for a tool" and "the function ran" there are six steps. Put them all in one place, so every tool gets them for free.
Learning objectives
- Build a tool registry that generates schemas from function signatures and rejects duplicate names.
- Implement a dispatcher with six stages: resolve, parse, validate, hooks, run with a timeout, serialise.
- Return a typed result for every call (ok, or one of five error types), and keep per-tool statistics.
- Measure how many real model calls fail validation, and recover them with lossless argument coercion.
Lesson 1 ran tools with a three-line runtool. That works until:
Loading the full lesson…