Module 4 · What the model can see

Tool use, with the magic removed

In this lesson

  • 8 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 7 of 9 in this chapter

This chapter’s goalBudget a context window across system prompt, history, retrieved material and output; predict where in a long prompt information is most likely to be missed; and explain why prompt injection is a structural property of the input format rather than a bug awaiting a patch.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 7Free · no account needed
Lesson steps

The loop, in full

Tool use sounds like the model reaching out into the world. It is not. Here is every step:

  1. You include descriptions of the available tools in the prompt: names, parameters, what each does. These are tokens like any other.
  2. The model generates text that, by a convention it was trained on, represents a call: a name and some arguments, usually as JSON.
  3. Your code parses that, decides whether to run it, runs it, and gets a result.
  4. You put the result back into the context as a new message.
  5. The model generates again, now with the result available.

The model emits a string. Everything that happens as a consequence is your program’s doing. This is worth being blunt about, because the security implications in the rest of this module rest on it.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the AI, Actually Explained exam.

Stuck on something?Ask Anjali, your AI tutor

How to cite: Addaly (2026) ‘Tool use, with the magic removed’, in How a Language Model Actually Works. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/how-llms-work/tools-and-function-calling (Accessed: 29 November 2026).