Function calling
Why it matters
This is the step from a chatbot that talks to an assistant that acts. Without it, a model can describe how to check an order. With it, the model checks the order, using the real data rather than a guess, which also reduces made-up answers. It also moves part of the reliability problem onto the functions. The model chooses which one to call and what to pass in, so clear descriptions and checks on your side decide whether it behaves.
How to apply it
- Describe each function narrowly: what it does, what it needs and what it returns.
- Validate every input before running it. A value is not safe because a model produced it.
- Keep functions small and single-purpose. A function that does too much gives the model more ways to misuse it.
- Start with read-only functions, and add write access later.
- Log every call and its inputs, so a wrong action can be traced.
- Add human approval before anything hard to reverse, such as sending money or deleting a record.
What it is
A language model on its own only produces text. Function calling lets it ask for something to be done. The developer describes a set of functions, each with a name, a purpose and the inputs it needs. When the model decides one is useful, it replies with the function name and the values to pass in. The surrounding software runs the function and hands the result back, and the model carries on with that result in front of it.
The model never runs anything itself. Your code does, and your code decides whether to allow it. Different AI providers use different names for the same idea, mostly tool use or function calling.
Common mistakes
- Trusting the arguments. The model may pass an order number that belongs to another customer. Check permissions in your code, not in the prompt.
- Vague descriptions. If two functions sound alike, the model picks the wrong one. Say what each does, and when not to use it.
- Giving write access too early. A model that can send, delete or pay can do real damage on its first wrong guess. Start with read-only functions.
- One large function. A function that does five things gives five ways to go wrong and is hard to log or test.
- No log. Without a record of each call and its inputs, a wrong action cannot be traced.
- Leaving out errors. If a function fails and the model is not told clearly, it may carry on as if it succeeded.