Tool calling, explained: how a language model uses software
When an assistant checks the weather, books a slot, or looks up an order, it can feel like the model reached out and did it. It didn’t. A language model only produces text. Tool calling is a convention for making that text useful.
The loop
You describe the tools available: a name, what it does, and what inputs it takes. The model, reading a request, may reply with a structured message saying which tool it wants and with what inputs. Your code reads that message, runs the tool, and sends the result back. The model then continues with that result in front of it.
Figure 1 · One round of tool calling
Why this matters
- You decide what is possible. The model can only ask for tools you listed. It can’t run anything you didn’t wire up.
- Permissions live in your code. Check inputs, limit access, and require approval before irreversible actions. We say more in the note on prompt injection.
- Descriptions are instructions. A vague tool description produces wrong calls. Write them like you would brief a new colleague.
Common problems
- Too many tools. The more options, the more wrong picks. Start with a few.
- Errors with no explanation. If a tool fails, return a clear message so the model can try something else.
- Endless loops. Cap the number of rounds, so a confused agent stops instead of running up a bill.
- No record. Log every call and result, or you will not be able to explain a bad outcome later.
Standards like MCP make tools easier to share between apps, and the harness is the layer that runs this loop and enforces the rules around it.