liveBook · Manning

Chapter 2: Working with Tools

What you will learn in chapter 2 of Build a Multi-Agent System (from Scratch)

This introduction explains how tools expand LLM agents’ capabilities and outlines the basic tool-calling process.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction explains how tools expand LLM agents’ capabilities and outlines the basic tool-calling process.

Key terms: tools, LLM agents, textual description, tool-calling process, tool-call request

2.1 BaseTool: a blueprint for tools

This section introduces a standardized tool interface, the data structures used in tool calls, and their representation in UML.

Key terms: BaseTool, textual descriptions, standard interface, ToolCall, ToolCallResult, __call__(), name, description, parameters_json_schema, id_

2.1.1 Implementing ToolCall and ToolCallResult

This section implements Pydantic data structures for representing tool-call requests and their execution results.

Key terms: ToolCall, id_, tool_name, arguments, ToolCallResult, tool_call_id, content, error, pydantic.BaseModel, model fields

2.1.2 Defining BaseTool

This section defines the BaseTool interface, explains its use of JSON Schema, and implements a Hailstone tool as an example subclass.

Key terms: BaseTool, name, description, parameters_json_schema, __call__, @abstractmethod, JSON Schema, properties, required, type

2.1.3 The AsyncBaseTool

This section introduces AsyncBaseTool, explains its non-blocking execution and interface, and describes how to call asynchronous Python functions.

Key terms: AsyncBaseTool, BaseTool, asynchronous execution, blocking, concurrent execution, __call__(), async, coroutine, await, asyncio.run()

2.2 SimpleFunctionTool: a subclass of BaseTool

This section introduces function-wrapping tool classes and contrasts their synchronous and asynchronous forms.

Key terms: SimpleFunctionTool, BaseTool, name, description, parameters_json_schema, __call__(), AsyncSimpleFunctionTool, AsyncBaseTool, func

2.2.1 Implementing SimpleFunctionTool

This section implements SimpleFunctionTool by deriving tool metadata and a parameter schema from a Python function, then validating and delegating tool calls to it.

Key terms: SimpleFunctionTool, BaseTool, func, name, description, function_signature_to_json_schema(), parameters_json_schema, function signature, JSON Schema, default values

2.2.2 The AsyncSimpleFunctionTool

This section adapts automatic function-tool creation to asynchronous Python functions, highlighting the constructor and call differences from SimpleFunctionTool.

Key terms: AsyncSimpleFunctionTool, SimpleFunctionTool, func, __call__, await, Callable[…, Awaitable[Any]], typing.Awaitable, typing.Coroutine, asyncio.Futures, asyncio.Tasks

2.3 PydanticFunctionTool: another subclass of BaseTool

This section introduces PydanticFunctionTool as a function wrapper that uses Pydantic for tool parameter schemas and validation.

Key terms: PydanticFunctionTool, BaseTool, pydantic.BaseModel, ToolCall, parameters_json_schema, __call__, BaseModel.model_json_schema(), BaseModel.model_validate()

2.4 Extending to MAS: Tools

This section connects the chapter’s tool abstractions to agent specialization and subtask delegation in multi-agent systems.

Key terms: SimpleFunctionTool, AsyncSimpleFunctionTool, Pydantic, JSON schema validation, tools, responsibilities, MAS, dispatching, subtasks, LLM agents

2.5 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 1: What are LLM Agents and Multi-Agent Systems? Chapter 3: Working with LLMs →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.