liveBook · Manning

Tool use

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.

A user asking for today’s news needs information a language model may not have in its context. With tool use, an AI system can invoke external software to obtain information or perform an action, then use the result in its response. For example, a model can issue a web search and summarize the returned documents. section 8.11

A tool call is a structured request specifying a tool and the inputs it needs. The surrounding system executes the request and returns the result to the model. Models can learn when and how to make calls through fine-tuning, or be given examples of tool invocations in a system prompt without additional training. 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”

Compare inputs and outputs for search, calculation, translation, and other tools. section 8.11

Some agents make at most one tool call for a user query. More flexible architectures return each result to the model, allowing it to choose another action. Longer sequences can handle multistep tasks, but they also make it harder to keep track of intermediate results. section 8.12

Combining a spreadsheet with web search

To find the review rating of a restaurant franchise’s highest-grossing location, an agent could read and analyze a sales spreadsheet, identify the location, and then search the web for its current rating. section 8.12

Tool access can make mistakes consequential: an agent might delete files, send emails, or disrupt reservations. External content can also carry hidden instructions that redirect an agent into unsafe actions, an attack called indirect prompt injection. Restricting available actions and requiring human approval before execution are ways to limit these risks. section 8.20

A correct answer alone does not reveal how reliably an agent used its tools. Search results can be misleading or lack the answer, prompting a wrong or fabricated response. Benchmarks can test task completion, while red teaming probes for failures such as unintended or hallucinated tool calls and multistep errors. section 8.16 section 10.22

How Introduction to Generative AI, Second Edition covers it

How deep it goes
Explains structured calls, result handling, training approaches, and repeated invocation at an overview level.
Examples
Illustrates web search for current news and a restaurant sales spreadsheet followed by a review-rating search.
What you can do after
Evaluate tool-enabled agents by considering task success, search failures, unsafe actions, and adversarial testing.
How it connects
Connects tool use with agent architectures, retrieval, prompt injection, and red teaming.

Also explained in

Compare how 14 books explain tool use →

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.