aiengineering.guideaiengineering.guide

Working SWE → AI engineer · Stop 7 of 15 lessons

Tool use, from three lines of Python

What this lesson covers

Tool use is the mechanism that turns a language model into the reasoning core of a system. It looks like magic; it’s a loop. This lesson makes the loop concrete.

The outline

  1. The core idea. A model that can emit {"tool": "search", "query": "..."} instead of an answer, so you can run the search and give it the result.
  2. Building the loop from scratch. Twenty lines of Python that show exactly what the SDK does — nothing hidden.
  3. The tool-use API. How Anthropic and OpenAI standardise the same pattern. What changes and what doesn’t.
  4. Writing schemas models understand. Description quality, argument naming, and the enum trick that eliminates half of tool-call bugs.
  5. The four common tools. Search, code execution, file IO, HTTP — and the security posture each one demands.
  6. What tool use is not. The difference between one call with tools and a full agent loop (next lesson).

Coming soon

In outline.

Outline

Enter to go · Esc to close