AI Agents

Tool Calling: How AI Agents Take Action

Read a tool definition, follow one call from request to result, and decide which controls your own agent needs.

Model Application Tools request result

The short answer

Tool calling, also known as function calling, lets a language model request an action from your software. You describe each tool with a name, a description and an input schema. The model returns a structured request, your application runs it and sends back the result, and the model uses that result to continue.

What is tool calling?

Tool calling is the mechanism that lets a large language model, the text-predicting system behind ChatGPT, Claude and Gemini, ask your software to perform an action. OpenAI's documentation uses the name function calling, and Anthropic's uses tool use. Both names describe one mechanism.

A model on its own produces text. It cannot open your spreadsheet, send an email or read today's orders. Tool calling closes that gap with a division of labour: the model chooses the action and fills in the details, and your application carries the action out. The model holds no password and touches no system. It writes a request, and the software around it decides whether to run that request.

That division separates a chatbot from an AI agent. An agent is a model that works towards a goal by calling tools in a loop, reading each result before it picks the next step.

How does the tool calling cycle work?

The cycle has three steps, and it repeats until the model has enough to answer.

  1. The developer describes the tools. Each tool gets a name, a description in plain language, and an input schema, a structured list of the fields the tool accepts and the type of each field. On a no-code platform you fill in a form and the platform writes the schema for you.
  2. The model returns a structured request. The model reads the user's message alongside the tool descriptions. If a tool would help, it replies with the tool's name and a set of arguments that fit the schema, in place of a sentence for the user.
  3. The application runs the tool and returns the result. Your code, or the platform, executes the request and sends the output back to the model. The model reads the result, then calls another tool or writes its answer.
Model Application Tool message and tool list structured request runs the tool output tool result repeats The model stops calling tools once it can answer.
The model talks only to the application, and the application alone reaches the tool.

The model sees a tool result as more text in the conversation. A failed call arrives as an error message, and a capable model can read that message and try again with corrected arguments. How AI agents work covers the full loop, including how the agent decides to stop.

Why does the tool description matter as much as the prompt?

The description is the only information the model has about a tool. The model cannot see the code behind the tool, so it picks tools and fills in arguments from the name, the description and the schema alone.

What the model sees name write_row_to_spreadsheet description Adds one new row to the Leads sheet. Use once per enquiry. input schema full_name: text email: valid address received_on: date What it cannot see Code behind the tool hidden from the model
Three written parts are all the model gets, so each one has to do the explaining the code cannot.

Write the description the way you would brief a new colleague. State the job the tool does, the situations that call for it, and the situations that call for a different tool. Give the format of each field: a date as year, month, day, or an amount as a number without a currency symbol. Say what the tool returns.

Compare two descriptions for one tool. The first reads "Updates sheet." The second reads "Adds one new row to the Leads sheet. Use it once per enquiry, after you have checked that the email address is present. Do not use it to change an existing row." With the first, the model guesses. With the second, it knows the tool's job and its limit.

Anthropic's guide to building agents recommends giving tool definitions the same care you give the main prompt, and testing how the model uses each tool before you rely on it.

A worked example: writing a row to a spreadsheet

A tool that writes one row to a spreadsheet shows the whole cycle in four moves: definition, request, execution, result. I built an intake agent in n8n that receives a form submission, applies five business rules written in plain language, and records the enquiry. One of its three tools writes a row to a Google Sheet. A simplified version of that tool definition looks like this:

name: write_row_to_spreadsheet
description: Adds one new row to the Leads sheet.
  Use once per enquiry, after the rules check.
  Does not edit or delete an existing row.
input:
  full_name    text, required
  email        text, required, a valid email address
  enquiry      text, required, one of: course, corporate, other
  received_on  date, required, format YYYY-MM-DD

Suppose a visitor named Mei Ling submits the form with her email address and a question about a corporate workshop. The agent reads the submission and returns this request:

tool: write_row_to_spreadsheet
arguments:
  full_name: "Mei Ling Tan"
  email: "meiling@example.com"
  enquiry: "corporate"
  received_on: "2026-11-29"

At this point the model has written a request and changed nothing. n8n receives the request, checks the arguments against the schema, and calls Google Sheets. The sheet confirms the new row, n8n passes that confirmation back to the model, and the model moves to its next step: a welcome email. The workflow pauses there so a person can approve the email before Gmail sends it.

What goes wrong with tool calling?

Expect three kinds of failure: wrong arguments, the wrong tool, and an action nobody approved.

  • Wrong arguments. The model puts the date in the wrong format, invents a value for a field the form left blank, or writes "Corporate training" in a field that accepts three fixed values.
  • The wrong tool. Two tools with similar descriptions confuse the model. It sends an email in a situation that called for a lookup, or updates a record it should have created.
  • Acting without approval. The model sends a message or deletes a record that a person should have reviewed first. A model can also follow instructions hidden in a document or web page it reads, an attack known as prompt injection.

Which controls keep tool calling safe?

Three controls cover those failures: narrow tools, validation and approval steps. Each one lives in your application, outside the model, so it holds on the occasions the model makes a mistake.

  • Narrow tools. Give the agent a tool that adds one row to one sheet, in place of a tool that can edit any file in the drive. A narrow tool limits the damage of a bad call. Keep the list short too, since each extra tool gives the model one more wrong choice to make.
  • Validation. Check the arguments in code before the tool runs. Reject a malformed email address or an unknown category, and return a clear error so the model can correct itself.
  • Approval steps. Pause before an action you cannot undo, such as sending an email, issuing a refund or deleting data. A person reads the proposed action and approves or rejects it.

Sort your tools into two groups before you build. Tools that read, such as a lookup or a search, can run without review. Tools that write, send or pay need validation as a minimum, plus an approval step wherever a mistake would reach a customer.

Tool request Validation Tools that read Approval Tools that write, send or pay Tool runs error goes back
Every request meets validation, and only the tools that change something wait for a person.

Two later decisions build on this one. If you want the same tools available in more than one AI application, the Model Context Protocol standardises how you publish them. If the tool list grows so long that the model starts picking the wrong one, consider splitting the work across several agents.

Common questions

Is tool calling the same as function calling?

Yes. OpenAI introduced the feature under the name function calling, and Anthropic documents it as tool use. All three terms describe a model returning a structured request that your application runs.

Does the model run the tool itself?

No. The model writes a request naming the tool and its arguments. Your application or automation platform runs the tool, which means you can validate, log or block a request before anything happens.

Do I need to write code to use tool calling?

No. Workflow platforms such as n8n let you attach tools to an agent by filling in a name and a description, and the platform builds the schema. Writing code gives you finer control over validation and error handling.

Sources and references

  1. OpenAI, Function calling
  2. Anthropic, Tool use with Claude
  3. Anthropic, Building effective agents

Concepts covered: tool calling, function calling, input schema, tool description, AI agent, human approval, prompt injection.

Weekly newsletter

The AI Brief by Clarence Cheang

A weekly exploration of the developments, technologies and ideas shaping artificial intelligence.

One email a week. Unsubscribe in one click. What is in each issue