Acting — How Tools Get Invoked
Tripmate has decided its next step: search trains from Pune to Jaipur for Thursday night. But a language model can only produce text. It cannot open a connection to a railway website. So how does a decision become an action?
The rule
The model writes a request; your code does the deed.
A tool is a function your program offers to the model, described by a name, a purpose and the inputs it takes. When the model wants to act, it does not run anything. It writes a structured tool call — which tool, with which arguments:
{
"tool": "search_trains",
"arguments": { "from": "Pune", "to": "Jaipur", "date": "2026-10-15", "class": "sleeper" }
}Your program then does four things:
- Reads the call and checks the tool name exists.
- Validates the arguments — right types, allowed values, permission to act.
- Runs the real function, such as an API request to a timetable service.
- Returns the result to the model as a new message, so the next turn can use it.
Many model providers support this directly: you pass tool descriptions with the request, and the model's reply can contain tool calls in a fixed format instead of plain text. The exact field names differ between providers, but the shape is the same everywhere.