Notes

Function Calling

A language model cannot check your calendar. What it can do is produce, in a format a program will accept, the exact request that would check your calendar — and let the surrounding code make the call. Function calling is that mechanism: the model selects a declared function and fills in its arguments, the runtime executes it, and the result comes back as the next thing the model reads.

How one call works

  • The application declares each available function as a schema — name, description, typed parameters — and sends it alongside the prompt.
  • The model answers with a structured call rather than prose: the function name plus a JSON object of arguments, validated against that schema.
  • The runtime executes it and appends the return value to the conversation as an observation.
  • The model reads that result and either calls another function or answers.

Why the agent loop depends on it
Function calling is the bridge between generating text and taking action; without it an agent can only describe what should happen. It is also the layer where agents fail most visibly. A plausible-but-wrong argument gets executed exactly as written — a date parsed into the wrong year, a customer id lifted from the wrong line of a tool result. A vague function description makes the model pick the wrong one from twenty. And since nothing in the mechanism verifies intent, destructive functions need validation outside the model. The Model Context Protocol standardises how these declarations and results travel, so one function definition serves any client that speaks it.

Function calling is the mechanism by which a language model requests an external operation: given a set of declared function schemas, it emits a structured call — a function name plus typed arguments — which the application executes and returns as an observation. The model never runs anything itself. This is the bridge from generated text to real action, and the point at which an agent can act on a confidently wrong argument.

Picture ordering at a busy café. You do not walk into the kitchen — you fill in a slip with the drink, the size and the milk, and hand it over. Function calling works the same way.

An AI that writes text cannot, by itself, send an email or look up a price. So it is given a short list of things it may request, each with a form to fill in. It fills one in, the surrounding software carries it out, and the result comes back. That is how a chatbot becomes something that gets things done — and where care is needed, because a form filled in from a confident guess still gets carried out.