Skip to content

Tool use

A tool call is the model asking your program to do something: look up a name in the GND authority file, ask Wikidata a question, run a SPARQL query. The model only proposes the call. A person approves, corrects or refuses it, Python runs it, and the result goes back to the model.

Notebook 05, 05_tool_use, takes about 15 minutes in the workshop. It defines three tools as plain Python functions and shows the gate, the step where you decide whether a call runs. It then corrects a misspelled name, chains a GND lookup to Wikidata and the Historical Dictionary of Switzerland, and deliberately triggers the failure the loop is built to catch: an identifier the model made up.

What the notebook covers

  1. Define tools as plain Python functions with docstrings.
  2. Let the model propose a call; approve it, correct it or refuse it; feed the result back.
  3. Chain two tools: GND identifier, then Wikidata, then the Historical Dictionary of Switzerland.
  4. Recognize the failure modes (the ways the model goes wrong) and what the loop does about them.
Run this chapter’s prompts in English. In one of the October 2026 tests, the 8B model called a tool for every English prompt and for only 1 of 9 German prompts.

The pages

Tool use builds on structured output, because a tool call is a small structured record. It also builds on RAG, for the questions a document index cannot answer.