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.
The shortcut
Picture a waiter and a kitchen. The model is the waiter: it takes the order and writes a ticket. Your code is the kitchen: it checks the ticket, cooks, and sends the plate back. Whenever you wonder "can the model do X?", ask "is there a ticket for X, and will the kitchen accept it?"
Model writes the ticket
Tripmate emits a call to
search_trainswith Pune, Jaipur, 15 October, sleeper.
The trap is trusting the ticket blindly. Models sometimes invent a tool that does not exist, pass a malformed date, or request an action they should not take. Validation in your code is the safety net, and anything risky — like book_ticket, which spends money — deserves a confirmation step.
Drills
Answer fast — trust the rule.
What does a model produce when it "calls" a tool?
Tripmate asks for search_trians (a typo). What should the program do?
How does the model learn what search_trains returned?
Which Tripmate tool most needs a confirmation from Asha before it runs?
Remember
- The model writes a tool call; your code validates it, runs it and returns the result.
- Shortcut: waiter and kitchen — is there a ticket, and will the kitchen accept it?
- Trap: running tool calls without validation, especially ones that spend money or change data.
