How does function calling (tool calling) work, and who actually executes the tool?
Short answer
The model executes nothing: it only returns a tool-call proposal (name + arguments). Your application code decides whether to run it, runs it, sends the result back, and loops until the model finishes answering.
3 points to say:
- The model only returns
tool_calls; the application is the one calling APIs. An agent is that loop with many self-chosen steps. - Tool descriptions decide which tool the model picks and how it fills the arguments.
- Permissions, argument checks, idempotency, audit all live in the tool code, not in the prompt.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.