Tool use – Mangrove

AI GlossaryAgents and tools

Tool use

Definition: Tool use is when an AI model requests a call to an outside program, such as a search or a trading API, and software runs it and returns the result.

Tool use is also called function calling. The developer describes each tool to the model with a name, a description and the inputs it accepts. When the model decides a tool would help, it returns a structured request that names the tool and gives its arguments, such as a ticker symbol and an order size. The model does not run anything itself. The application runs the tool and sends the result back for the model to read (Anthropic documentation).

This is the point where a model’s errors can become actions. Unless code between the model and the tool checks them, the model’s arguments reach the tool as written. For example, an agent that misreads its account balance may request an order ten times larger than intended, and the order will be placed unless a check stops it. Text also flows the other way, from the tool’s output into the model’s context. When OpenAI added function calling to its API in 2023, it warned that untrusted data in a tool’s output can instruct the model to take unintended actions, and it advised developers to ask the user to confirm actions with real-world impact, such as making a purchase.

In Mangrove’s system, every order an agent requests goes through position sizing rules, daily loss limits, drawdown limits and circuit breakers that run in code outside the model. A refused entry is recorded with the reason it was refused.

Several research systems gave language models tools before the feature reached commercial APIs. WebGPT (Nakano et al., 17 December 2021) fine-tuned GPT-3 to search and navigate the web through a text-based browser. ReAct (Yao et al., 6 October 2022) had a model interleave reasoning steps with actions, such as queries to a Wikipedia API. Toolformer (Schick et al., 9 February 2023) trained a model to decide which APIs to call, when to call them and what arguments to pass, using tools that included a calculator, two search engines and a calendar. OpenAI added function calling to its API on 13 June 2023, and Anthropic’s documentation treats tool use and function calling as two names for the same feature.