Rerun is now open source under AGPL-3.0Star us on GitHub
Rerun

Tool Calling in AI Agents: How It Works and How to Govern It

Tool calling is how an AI agent stops answering and starts acting. Learn the loop, the schemas, the failure modes and how to govern every call.

Tool Calling in AI Agents: How It Works and How to Govern It

The best of 19 models tested on ToolFailBench reached an 86.33% clean tool-use rate. That is the headline from a July 2026 ICML workshop paper built on 1,000 tasks in finance, medicine, law, cybersecurity and real estate, and its authors conclude that faithful tool use "is not saturated". In plain terms, even the best model shows some tool-use failure, such as skipping a needed tool, ignoring a result or inventing an output, on roughly one task in seven. Tool calling is how an AI agent stops talking and starts acting, and it is also where most agent failures begin. Unlike a Zapier flowchart, where you picked every tool in advance, an agent picks its own tool and arguments at run time, so each call needs supervision.

This guide explains tool calling in AI agents from the ground up: what it is, how the loop works, where it breaks, and how to keep every call under control once agents touch real systems.

In a hurry? Jump to the failure modes or the production checklist.

Key takeaways

  • Tool calling means the model requests an action in a structured format. Your software executes it.
  • Function calling, tool calling and AI agent tool use are the same mechanism with three names.
  • The gap between the request and the execution is the best control point in any agent system.
  • Most failures are wrong arguments, ignored results and silent errors, not dramatic crashes.
  • Allow-lists, approval gates and a log of every call turn a demo into something you can run on a Monday morning.

What is tool calling in AI agents?

Tool calling is the ability of a language model to output a structured request to run an external function, which the surrounding application executes before returning the result to the model. The model never touches your calendar, your CRM or your database. It writes down which tool it wants and with which arguments, and your code decides what happens next.

That one sentence is the whole idea. IBM describes it as a key enabler of agentic AI, because it turns a model that only answers questions into one that can query databases, fetch live information and carry out multistep work.

What Is Tool Calling? | IBMWhat Is Tool Calling? | IBMTool calling refers to the ability of AI models to interact with external tools, APIs or systems to enhance their functions.ibm.com

Tool calling vs function calling vs tool use

AI agent tool use goes by three names in documentation. They describe the same mechanism, so do not let the vocabulary slow you down.

TermWho uses itWhat it means
Tool callingIBM, most framework docsThe model emits a structured call to an external tool
Function callingOpenAI, the original termThe same thing, historically framed as calling a function you define
Tool useAnthropicSame mechanism, described as tool use (also called function calling)

Anthropic's documentation says it directly: tool use "also called function calling" lets the model call functions you define or that the provider supplies. OpenAI's guide describes the same loop. For the rest of this article, tool calling AI agents and function calling AI agents mean the same thing.

Why language models need tools

A model on its own is a frozen snapshot of its training data. Early models, including GPT-2, were static: they could not check a stock price, read today's inbox or create a ticket. Tools fix that. They give the model eyes (search, retrieval), hands (APIs that change something) and a calculator (code execution), without retraining anything.


How tool calling works, step by step

Every provider of tool calling for AI agents implements the same five-step loop, with different field names.

  1. Define the tools. You send the model a list of tools, each with a name, a description and a JSON schema for its arguments.
  2. The model decides. Given the user request and the tool descriptions, the model either answers directly or returns a structured tool call.
  3. Your application executes. Your code validates the arguments, runs the function and captures the result.
  4. The result goes back. You send the output to the model, linked to the original request by a call ID.
  5. The model continues. It writes the final answer, or requests another tool call, which restarts the loop.

Here is what the model returns in step 2 for a weather question, using the Anthropic format:

{
  "type": "tool_use",
  "id": "toolu_01A09q90qw90lq917835lq9",
  "name": "get_weather",
  "input": { "location": "San Francisco, CA" }
}

Your code runs the lookup and answers with a tool_result block that carries the same ID. OpenAI uses a call_id for the same purpose. IBM notes that this unique ID works like a tracking number that links each request to its result, which is exactly why it matters for logging later.

The anatomy of a tool definition

A tool definition has four parts that matter:

  • Name: a short, unique identifier such as create_invoice.
  • Description: plain language telling the model when to use the tool. This is the model's main selection signal, so vague descriptions produce wrong choices.
  • Parameters: a JSON schema with types, required fields and enums.
  • Strict mode: both OpenAI and Anthropic support a strict flag that forces calls to match the schema exactly.

Write descriptions as if you were briefing a new hire who cannot ask questions.

Who actually runs the tool?

Anthropic splits tools by where the code runs. Client tools run in your application: the model returns a call, your code executes it and sends back the result. Server tools, such as web search or code execution, run on the provider's infrastructure and return results directly.

The model never executes anything. It asks. Your runtime answers.

Keep that sentence in mind, because everything about safety follows from it. Between the request and the execution there is a moment where software, not the model, holds the decision.

Rerun connects coworkers to 3,000+ integrations plus any MCP server

From one call to an agent loop

A single tool call answers a single question. An agent chains them: the model calls a tool, reads the result, decides the next step and calls again until the task is done. If you want the reasoning side of that loop, our guide to ReAct agents covers how a model alternates between thinking and acting, and agentic design patterns places tool use alongside reflection, planning and multi-agent work.

This article zooms into the Act step only, and the agent harness is the software that runs that loop around the model.

Parallel tool calls

Models can request several tools in one turn, for example checking three customers at once. Parallel calls are faster, but they overlap in time, so two calls that touch the same record can collide. Anthropic exposes a flag to disable parallel tool use when order matters.

Controlling tool choice

You are not forced to let the model decide freely. Providers let you steer it:

SettingBehaviorUse it when
AutoThe model chooses to call a tool or answerDefault for most agents
Required or anyThe model must call some toolA step must always act, such as routing
Forced toolThe model must call one named toolStructured extraction into a fixed schema
NoneTools are visible but cannot be calledReasoning-only turns

Types of tools that tool calling AI agents use

Not all tools that tool calling AI agents use carry the same risk. Sorting them by what they can break is the most useful habit you can build.

Tool typeExampleRisk level
Retrieval and searchWeb search, database lookupRead-only
Code executionRunning Python in a sandboxContained, but can burn compute
Process automationCreate calendar event, update CRMReversible write
CommunicationSend email, post to SlackIrreversible, external
Money and recordsIssue refund, delete rowsIrreversible, high impact
Computer useClick and type in a real UIBroad, hard to scope

This table is the seed of a governance policy. Read-only tools can run freely. Irreversible tools need a gate.


Tool calling vs MCP vs skills

Three terms get tangled, and they sit at different layers.

LayerWhat it isQuestion it answers
Tool callingThe model-level mechanism for requesting an actionHow does the model ask?
MCPAn open standard for discovering and connecting toolsWhere do the tools come from?
SkillsReusable instructions for a type of taskWhen and how should the tools be used?

The Model Context Protocol standardizes how tools are exposed, so one connector works across many clients. If you want to publish your own, how to build an MCP server walks through it. Agent skills sit above both: they package the know-how that tells an agent which tool to reach for and in what order. MCP supplies tools, tool calling invokes them and skills teach judgment.


Where tool calling goes wrong

This is the section most explainers skip, and it is where production agents earn or lose trust.

Wrong tool or invented arguments

Anthropic documents this itself: when a required parameter is missing, Claude Sonnet "might also infer a reasonable value", so a bare "What's the weather?" can come back with a guessed city. A guessed city is harmless. A guessed customer ID on a refund is not. Fix it with strict schemas, clear descriptions and validation in your code before anything executes.

Ignored results and fabricated outputs

ToolFailBench separates failures into four labels: skipping a needed tool, ignoring its result, fabricating an output and calling a tool when none was needed. Models with similar overall scores fail in different ways, so a single accuracy number hides the pattern. A separate validity audit of tool-calling benchmarks found an 18.5% evaluator-human misalignment rate across 496 reviewed tasks, which means even the scoreboards need skepticism.

Too many tools

Every tool definition costs tokens and competes for the model's attention. Long tool lists are expensive and can blur selection. Anthropic's answer is a tool search tool that discovers and loads tools on demand instead of listing thousands up front.

Irreversible actions

A model that is 95% right is wrong once in twenty calls. For read-only lookups that is a retry. For a sent email or a deleted record it is an incident. This is the same pattern behind prompt injection attacks, where hostile text steers a tool call that you never intended.

Silent failures and no audit trail

If a call fails and nobody logged it, you find out from a customer. If a call succeeds with the wrong value and nobody logged the arguments, you cannot even reconstruct what happened. Logging each call with its arguments, result and caller is the minimum.

Cost

Tool use is not free. Anthropic lists a tool-use system prompt of 286 tokens on Claude Sonnet 5.5 when you provide tools, on top of your schemas and every tool result sent back. A five-step loop with large schemas multiplies that on every round trip.


Making tool calls safe and observable in production

Treat every tool call as a policy decision, not a function call. Because your runtime sits between the model's request and the real action, you can attach controls at exactly that point.

The controls behind this list have their own deep dives: AI agent guardrails covers policy design, human-in-the-loop AI agents covers approval patterns, and AI agent observability covers tracing.

Approve or reject risky coworker actions from the app or Slack before they run

Zapier and Make run fixed, pre-mapped paths: you chose the tool and the arguments when you drew the flowchart, so there is nothing for a gate to review at run time (see Rerun vs Zapier and Rerun vs Make for the longer comparison). A chatbot sits at the other end: it waits to be asked and rarely acts on its own, which is why an AI agent is not a chatbot. When an agent chooses the tool and the arguments itself, you need approval gates and a log at every call.

Human-in-the-Loop AI Agents: The Complete Guide to Agents You Can Deploy

Human-in-the-Loop AI Agents: The Complete Guide to Agents You Can Deploy

Human-in-the-loop AI agents pause on high-stakes actions to get human approval. Here are the approval gates, confidence thresholds, and escalation patterns that make agents production-ready.


Where Rerun fits, and where it does not

Everything above works the same whether you use OpenAI, Anthropic, LangChain or your own code. Rerun is not a framework, it does not define your tool schemas and it does not run the model's reasoning for you. If you are writing the loop yourself, you still write it.

What Rerun adds is the operations layer around agents that already call tools. On Rerun, these agents are called coworkers. Each coworker works in a private workspace with 3,000+ integrations plus any MCP server, every action lands in a log you can read, and a risky step can pause for your approval from the app or from Slack, then resume exactly where it stopped. That is the allow-list, the approval gate and the audit trail from the checklist, without building them yourself.

If your agents touch code and infrastructure, here is a coworker that already runs a common engineering job:

Setup takes minutes, and every tool call it makes is visible in the log.


Tool calling checklist before you ship

The short version

For tool calling AI agents the contract is simple: the model requests, your software executes, the result returns. Because the model never acts on its own, you always have a place to check, approve and record. Teams that use that gap well ship agents that do real work. Teams that ignore it find out about their tool calls from the incident report. Start with read-only tools, gate the irreversible ones and read your logs. That is how tool calling AI agents earn trust one call at a time.

Frequently asked questions

Is tool calling the same as function calling?

Yes. Tool calling, function calling and tool use describe the same mechanism: the model returns a structured request to run an external function, and your application executes it. OpenAI popularized function calling, Anthropic says tool use, and IBM says tool calling.

How does AI agent tool use work?

AI agent tool use follows a five-step loop. You define tools with a JSON schema, the model decides whether to call one, your application executes the call, the result goes back to the model, and the model either answers or requests another call.

Does the LLM execute the function itself?

No. For client tools, the model only returns the tool name and arguments. Your code runs the function and sends the result back. Server tools such as web search run on the provider's infrastructure, but the model still does not run code on its own.

What is the difference between tool calling and MCP?

Tool calling is the model-level mechanism for requesting an action. The Model Context Protocol is a standard for exposing and discovering tools so one connector works across many clients. MCP supplies the tools, and tool calling is how the model invokes them.

Can an AI agent call several tools at once?

Yes. Major providers support parallel tool calls, where the model requests several tools in one turn. It is faster, but side effects can overlap, so teams disable parallel calls when the order of actions matters.

What goes wrong most often with tool calling AI agents?

The common failures are guessed or wrong arguments, ignored tool results, fabricated outputs, too many tools in the context and silent errors with no log. Benchmarks such as ToolFailBench show that even strong models fail in different ways, so test each failure mode separately.

How do I stop an agent from calling a dangerous tool?

Allow-list tools per agent, validate arguments in code before execution, and require human approval for irreversible actions such as refunds, outbound email and deletions. Log every call so you can audit what happened.

What is a tool schema?

A tool schema is the JSON schema that describes a tool: its name, a plain-language description, and the typed parameters it accepts. The model reads it to decide when to call the tool and how to fill in the arguments. Strict mode forces calls to match the schema.

How does Rerun work with tool calling?

Rerun is not a framework and does not replace your tool-calling stack. Its coworkers use tools through 3,000+ integrations plus any MCP server, and Rerun adds the operations layer: a log of every action and approvals that pause risky steps until a human says yes.

Back to blog

Related articles

2,000+ businesses run on Rerun

Hire Coworkers on the ChatGPT plan you already pay for.

  • 1. Plug in your subscription
  • 2. Set up your Coworkers
  • 3. Run your business with Coworkers