AI agents
Tool calling (function calling)
Tool calling, also called function calling, is a language model's ability to answer with a structured request to run a named function with arguments, which the application executes before handing the result back to the model.
What it is
A model on its own can only produce text. With tool calling, the application tells the model which functions exist, each with a name, a description and a JSON Schema for its arguments. When the model decides a function would help, it returns a structured call instead of prose. The application runs the function and sends the result back. OpenAI's documentation calls it function calling; Anthropic's calls it tool use. The idea is the same.
Why it matters
Tool calling is what turns a chat model into an AI agent. It lets the model read live data and take actions: look up an order, create a ticket, send an invoice. It also moves risk. Once a model can call a function that writes, a wrong guess becomes a wrong action in a real system.
How it works
OpenAI's guide describes the loop in five steps:
- Send the model a request with the tools it may call.
- Receive a tool call from the model.
- Run the code in your application with the arguments it chose.
- Send a second request with the tool's output.
- Receive the final answer, or more tool calls.
In Anthropic's API the model signals this with stop_reason: "tool_use" and a tool_use block; the application replies with a tool_result. Tools the provider runs itself, such as web search, are called server tools; tools your code runs are client tools. The Model Context Protocol standardises how the application finds those functions on other systems.
Example
Asked "what's the weather in Wellington?", the model returns a call to get_weather with {"location": "Wellington"}. The application calls a weather service and returns "14 degrees, windy". The model answers in a sentence.
Common pitfalls
- Invented arguments. Anthropic's documentation notes that when a required parameter is missing, a model may infer a plausible value rather than ask. Validate on the server.
- Duplicate writes. A retried call after a timeout can run twice. Use an idempotency key.
- Too many tools. Selection accuracy falls as the list grows. See tool overload.
- Policy in the prompt. "Never delete anything" in a system prompt is advice, not a control. See agent permissions.
How actionlake handles it
With actionlake, the server governs step 3, the execution. When an agent calls do, the server validates the arguments against the action's schema, checks the key's scope, reserves against its spending cap, holds the call for approval if a rule says so, deduplicates the write, sends it, and records the outcome in the ledger with the agent's stated intent. Before any of that, check runs the same validation as a free dry run. The platform page shows the full path.
Questions
Is function calling the same as tool calling?
Yes. OpenAI's documentation uses function calling and Anthropic's uses tool use; both describe a model returning a structured request to run a named function with arguments.
Does the model run the function itself?
No. The model only proposes the call. Your application, or the provider for server tools, runs it and returns the result.
How is tool calling related to MCP?
Tool calling is the model's ability. MCP is a protocol for discovering and invoking tools on other systems, so the same tool definitions work across different AI applications.
Related terms
- MCP toolAn MCP tool is a named function that an MCP server offers to AI models, described by a name, a plain-language description and a JSON Schema for its input, and invoked with a tools/call request.
- AI agentAn AI agent is software in which a language model decides its own next steps and tool calls in a loop, using results from its environment, until a goal is met or a stopping condition is reached.
- MCPThe Model Context Protocol (MCP) is an open standard that lets an AI application connect to external systems and discover and call their tools, read their resources and use their prompts through one JSON-RPC message format.
- Dry runA dry run checks whether an agent's action would succeed, whether it is allowed and what it would cost, by validating the inputs, permissions and connection without sending anything to the vendor.
- Idempotency keyAn idempotency key is a unique value attached to a write request so that if the same request is delivered twice, after a timeout or a retry, the server performs it once and returns the stored result for the repeat.
Sources
Connect an agent. Start free.
100,000 calls free every month. No card. Hard caps on every key.