AI 101

Function calling / tool use

How the model actually 'uses' a tool: it doesn't — it proposes a JSON call, the harness executes it. Plus the three classic ways it goes wrong.

By the end of this page — you can explain the tool-call protocol in three steps, read a real JSON tool call, and name the three ways tool use fails.

The phrase “the model calls a function” is a little lie. The model never calls anything — it has no hands. What it does is emit text that happens to be a well-formed function call. The harness runs it.

The protocol in three steps

  1. The harness advertises tools — names, descriptions and argument schemas — in the prompt, alongside the conversation.
  2. The model proposes a call — instead of a plain answer, it outputs structured JSON: which tool, with which arguments.
  3. The harness executes it and feeds the result back into the conversation, where the model reasons on.

A real call looks like this:

{
  "name": "calculator",
  "arguments": { "expression": "2 ** 100" }
}

The model “knows” it should use calculator because the harness told it: “calculator — evaluates a mathematical expression. Use it instead of doing the math in your head.” That one sentence is doing more work than you’d think.

The three classic failure modes

FailureWhat the model doesWhy it happensFix
🎯 Wrong toolCalls the wrong functionTwo tools with overlapping descriptionsSharper, contrasting descriptions
🧩 Wrong argumentsRight tool, garbage args (typos, wrong units, missing fields)The schema is loose or the input was ambiguousStrict JSON schema + validation + one retry
⏸️ Wrong timingKeeps calling tools when it should answer — or answers when it should callThe model can’t always see the whole taskClear “stop conditions” in the system prompt, step budgets
Tool descriptions are prompts — Writing a tool's description is prompt engineering. "Sends an email" is a coin flip; "Sends a **plain-text** email to a known contact. **Never** use for marketing. Requires a `to` address on file" is a decision the model can actually make. If an agent picks the wrong tool, the first thing to fix is usually the description — not the model.

Why MCP fits here

Function calling needs a channel: how do tool definitions get from one side to the other? Every vendor had its own wire format — the N×M integration mess. MCP is the shared plug: one tool server, many agents. The protocol above is the same; only the plumbing is standardized.