Tool Calling Function Calling
Tool calling (Function Calling) is the ability that lets a large model proactively output structured parameters in a conversation, with an external program executing the real operation. It turns the language model from "one that only talks" into an agent core that "can act", and is the most basic interface layer in almost all current agent systems and the channel through which model capability extends into the real world.
Core Principles
Mechanically, developers describe each available tool with a JSON Schema: name, functional description, parameter types, required items and enumeration ranges. These definitions are sent to the model with the request, and the model judges from the dialogue context whether a tool call is needed; if so it outputs a structured JSON containing the tool name and actual arguments rather than natural language. The application parses this JSON, validates it, actually executes the corresponding function, then passes the execution result back to the model as a new message, on which the model continues reasoning or generates the final reply. The whole process may loop for several rounds, forming a closed loop of "think, call, observe".
The model does not really execute code; it is only doing constrained text generation, so wrong parameter types, fabricated nonexistent tools, missing required fields and stuffing an explanation into a numeric field can all happen, which is why the outside must validate, tolerate errors and retry. The quality of tool descriptions directly determines the call success rate, more important than many people imagine.
Key Points
Formats differ markedly: OpenAI uses a separate tools field, each tool shaped as a nested type-plus-function structure containing name, description and parameters; Anthropic uses a tools array with the parameter field named input_schema, returning tool_use content blocks in the response. The return structure also differs: OpenAI returns via a tool_calls array and supports parallel tool calls, placing several independent calls side by side in one response so the application can execute them in parallel to reduce end-to-end latency; Anthropic likewise supports returning multiple tool blocks in one response.
Practical points: first, write descriptions as a manual for a new employee, stating when to call, when not to call and what is returned, which matters more than parameter names; second, use enumerations and explicit types for parameters and avoid free-text fields to reduce the model's room to improvise; third, ensure idempotency and timeout control, since the model may retry the same call and write operations must guard against duplication; fourth, control the number of tools, because dozens laid out flat markedly lower selection accuracy, so use hierarchical routing or dynamic injection by scenario; fifth, set a maximum loop count to avoid falling into infinite calls.
Common Misconceptions
First, writing a very detailed schema but forgetting the usage description, so the model has no idea when to use it. Second, assuming the model validates business rules, when in fact numeric ranges, permissions and balance checks must be done server-side and model output cannot be trusted. Third, shoving all interfaces in at once without classification or routing, so call accuracy decays rapidly as the number of tools grows.
An advanced practice is to combine tool calling with retrieval: the model first decides what to look up, then after obtaining the material decides whether to continue calling, and finally answers uniformly. Such multi-step chains must be paired with logging and replay to continuously tune prompts and tool descriptions. For high-frequency, highly deterministic operations, it is better to hard-code the flow than to have the model compute it each time.
Application Scenarios
Intelligent customer service order lookup, database queries, calendar scheduling, code execution, web search, order refunds, multi-step task automation, enterprise system integration, itinerary planning.