liveBook · Manning

Tool selection

As explained in Build an AI Agent (From Scratch)

Tool selection is the process by which a language model determines whether a tool is needed and chooses the appropriate available tool.

Tool selection is the model’s decision about whether a tool is necessary and which available tool best fits the request. Providing many tools increases context and makes incorrect choices more frequent; assigning focused tools to specialist agents reduces that confusion. section 9.1 section 3.2.1

A tool-selection cycle proceeds through a host-controlled feedback loop:

  • Provide the model with tool definitions, including names, descriptions, parameter schemas, and allowed values. section 3.2.1
  • Let the model answer directly when its existing knowledge is sufficient, or generate a tool call with a function name and arguments when computation or another action is needed. section 3.2.1
  • Extract the requested function and parse its arguments, then execute the function in the host system because the model cannot run code itself. section 3.2.1
  • Append the assistant’s call and the tool result to the conversation, then send the updated message history back for the final response. section 3.2.1

Direct answer or calculator call

With a calculator tool available, “What’s the capital of South Korea?” produces a plain-text answer and no tool call. “What is 1234 x 5678?” produces a calculator call with the multiply operator and operands 1234 and 5678; after execution, the final response is “1234 × 5678 = 7,006,652.”

Figure 3.3 Key steps in tool calling: tool definition, delivery, and LLM tool selection

Use the execution-flow diagram to trace tool definition, delivery, model selection, host execution, and result feedback. section 3.2.1

How Build an AI Agent (From Scratch) covers it

How deep it goes
Traces selection from schemas through host execution and feedback, stopping short of broader selection algorithms.
Examples
Contrasts a South Korea capital question with a calculator call for multiplying 1234 by 5678.
What you can do after
Apply it via tool calling to define tools, execute selected functions, and return results through conversation history.
How it connects
Connects tool selection with tool calling, function execution, message history, and multi-agent systems.

Also explained in

Compare how 2 books explain tool selection →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build an AI Agent (From Scratch). The section links point to the parts of the book it draws on.