Tool use

Tool use is an AI model's ability to call outside software, such as a search engine, calculator, database or code runner, by producing a structured request that an application carries out and returns the result of.

A language model on its own can only produce text. Tool use lets it do more. A developer describes each available tool to the model with a name, a plain-language description and a schema for its inputs. When a request needs a tool, the model replies with a structured call naming the tool and its arguments instead of a normal answer. The application runs the tool and sends the result back, and the model carries on. The term is often used interchangeably with function calling.

Anthropic's documentation gives a simple example. A user asks for the weather in San Francisco. The model returns a call to a get_weather tool with the location set to San Francisco, CA. The developer's code looks up the weather, returns a result such as 15 degrees and partly cloudy, and the model writes the answer. Some tools, such as web search and code execution, can run on the provider's own servers, so the developer does not have to handle them.

The idea developed quickly. ReAct, posted in October 2022, interleaved reasoning with actions such as searches. Toolformer, posted in February 2023, showed a model could teach itself, from a handful of demonstrations per tool, to use a calculator, a question answering system, search engines, a translation system and a calendar, often competitive with much larger models. On June 13, 2023 OpenAI added function calling to its API for gpt-4-0613 and gpt-3.5-turbo-0613.

Tools cover a model's weak spots: knowledge that is out of date, arithmetic, private company data and actions in the world such as sending a message. They are what turn a chatbot into an agent. How tools are written matters a great deal. Anthropic advises putting as much care into tool descriptions as into human interfaces, and reports that requiring absolute file paths in one tool removed errors that appeared after the agent changed directories.

Tools also bring risk. When OpenAI launched function calling in 2023, it warned that untrusted data in a tool's output could instruct the model to take unintended actions, and recommended asking users to confirm real-world actions such as sending email, posting online or making purchases. Anthropic's documentation notes that some models may guess a missing parameter rather than ask for it. Each tool definition and result also adds tokens, and so cost, to every request.

Common questions

What is tool use in AI?

It is the ability of an AI model to call external software, such as search, a calculator, a database or a code runner, to get information or take actions it could not manage with text alone. The model requests the tool in a structured format, an application runs it, and the result goes back to the model.

What is the difference between tool use and function calling?

They describe the same capability. OpenAI introduced the name function calling in 2023, and Anthropic's documentation says tool use is also called function calling. Tool use is sometimes used as the broader term, including tools that run on the provider's servers.

Does the AI model run the tool itself?

Usually not. The model only produces a request saying which tool to call and with what inputs; the developer's application runs it and returns the result. Some providers offer server-side tools, such as web search, that they run on the model's behalf.

Is AI tool use safe?

It depends on what the tools can do. A tool's output can contain text that tries to steer the model, a risk known as prompt injection, so tools should come from trusted sources. Actions with real-world effects, such as payments or sending messages, should need a person's confirmation.

Finding more

Search for "LLM tool use", "function calling API" or "Toolformer" to see how the capability works and how it developed. The API documentation of model providers is the most accurate source for current behaviour, and the original research papers on arXiv cover the history. Security guidance on prompt injection from AI developers and security bodies is worth reading before giving a model tools that can act on your behalf.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.