Chapter 5: Tools
Lecture
Chapter principle
Key takeaways
- A tool's executable capability and its model-facing description are different objects.
- Tool use is selection plus correct invocation.
- Tool descriptions and schemas shape model behaviour.
- A correct decision can still meet an execution failure; return it as a structured observation.
- Expanding the action space also expands the risk surface.
Experiments
Every experiment in the book is small, runnable and printed with its real output. In the Lab you can replay a recorded real run of each one, with no programming, and watch what the model and the agent do.
Experiment 8: One tool
How does a model's proposal turn into a real action?
The program describes one tool to the model, a calculator, and asks “What is 27611 times 2033?”. The model cannot run anything. It can only reply with a proposal: a tool name and its arguments. Software looks the name up in its registry, the list of tools it is willing to run, and runs the real function. This is a recorded run of a real model. A new run may differ: the model also decides whether to use the tool at all.
Experiment 9: Choosing between tools
How does a model choose between two similar tools?
The model gets two search tools: one over the company’s own documents and one over the public web. It must pick one for each of six questions. Three belong to each tool. No search actually runs: the experiment measures only the choice. Then the same two tools are offered again, with vague names and identical descriptions. This is a recorded run of a real model. A new run may pick differently.
Experiment 10: When a tool fails
What should the model be told when a tool fails?
The model asks for the weather in Pretoria, and the weather service times out. The same failure is handled twice. First, a wrapper hides it and passes on only “None”. Then a second wrapper reports it in a fixed format: what went wrong, and whether trying again could help. Each time, the model is then asked to answer the user. This is a recorded run of a real model. Its wording will differ in a new run.
All the code for this chapter: github.com/agentic-engineering-book/code
Download the bookBrowse all chapters