Tool calling
Tool calling, also called function calling, lets a model request that your code run a named function with structured arguments.
The model never executes anything itself. It returns a request, your code validates and runs it, and the result goes back into the conversation for the next step.
A tool is described to the model by a name, a description and a JSON Schema for its arguments. The model decides when to use it from that description alone, so the wording matters as much as the code.
Common mistake. Trusting the arguments. They come from a model that may have been misled by text it read, so validate them like input from the public internet.
In practice. Prefer narrow tools, return errors as results the model can read, cap result size, and put side effects behind approval.