liveBook · Manning

Tool usage

As explained in Introduction to Generative AI, Second Edition

Tool use is an AI system capability in which the system invokes external software, services, or functions to perform actions or obtain information.

Ask an AI assistant for today’s news, and it may search the web rather than rely on what it already knows. Tool usage is the ability to call external software or services, such as a search tool, calculator, file reader, or application programming interface (API), and use the returned result in a response. section 8.11

A language model can produce a structured tool call instead of ordinary prose. The tool runs, its result is placed back in the model’s context, and the model can then respond. Models may learn when and how to call tools through fine-tuning or through prompts that demonstrate tool use; a tool is not necessarily helpful for every request. section 8.11

Table 8.1 Sample API tool calls and output formats [49]

API name

Example input

Example output

Question answering

“Where was the Knights of Columbus founded?”

“New Haven, Connecticut”

Wikipedia search

“Fishing Reel Types”

“Spin fishing > Spin fishing is distinguished between fly fishing and bait cast fishing by the type of rod and reel used. There are two types of reels used when spin fishing, the open-faced reel and the closed-faced reel.”

Calculator

“27 + 4 * 2”

“35”

Calendar

(none)

Today is Monday, June 30, 2025.

Machine translation

“sûreté nucléaire”

“nuclear safety”

Sample inputs and outputs show the different kinds of results a tool can return, from a calculation or translation to a search excerpt. section 8.11

A question requiring several tools

To find the Google review rating of the highest-grossing restaurant location in an uploaded spreadsheet, an agent might read the file, analyze its sales figures, and then search for the current rating. A single tool call cannot complete that sequence. section 8.12

Longer tasks may require an agent to inspect one tool’s result before choosing its next action. That flexibility also creates risks: search results can mislead an answer, while access to email, files, or financial systems can turn a mistake into a consequential action. Malicious instructions hidden in retrieved content can redirect an agent. Limits on permitted actions, human approval, task evaluations, and adversarial testing help assess and contain these failures. section 8.12 section 8.16 section 8.20 section 10.22

How Introduction to Generative AI, Second Edition covers it

How deep it goes
Explains structured calls, returned results, training approaches, and repeated calls at a high level without implementing an API.
Examples
Uses web search for current news, sample calculator and translation calls, and a spreadsheet-to-review-rating task.
What you can do after
Evaluate/understand when an agent needs tools or chained calls and why external access requires safeguards.
How it connects
Connects tool usage to AI agents, web retrieval, planning, indirect prompt injection, and safety evaluation.

Also explained in

Compare how 13 books explain tool usage →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Introduction to Generative AI, Second Edition. The section links point to the parts of the book it draws on.