liveBook · Manning

SimpleFunctionTool

As explained in Build a Multi-Agent System (from Scratch)

SimpleFunctionTool is a book-specific tool wrapper that automatically exposes a synchronous Python function as an invocable agent tool.

SimpleFunctionTool wraps a synchronous Python function as a BaseTool that an LLM or agent can invoke. It derives the tool name from the function, uses its docstring as the description when available, and generates a JSON Schema for its parameters from the function signature. section 2.2 section 2.2.1

A tool call follows this flow:

  • Validate the call's arguments against the generated parameter schema. section 2.2.1
  • Pass valid arguments to the wrapped function and return its result in a ToolCallResult; report validation or execution errors in the result. section 2.2.1

Hailstone step

Wrap a function that computes one Hailstone sequence step. Its name, docstring, and integer input parameter provide the tool's metadata and schema, allowing an agent to invoke it with a value such as 3. section 2.2 section 2.2.1

Figure 2.14 Executing a SimpleFunctionTool involves validating the parameter data of the ToolCall object and subsequently delegating to the wrapped function.

The diagram summarizes argument validation followed by delegation to the wrapped function. section 2.2.1

How Build a Multi-Agent System (from Scratch) covers it

How deep it goes
Implements metadata generation, signature-to-schema mapping, argument validation, and execution; points to Pydantic-based schema generation as a more robust alternative.
Examples
Demonstrates wrapping a Hailstone sequence step function and invoking it with an input value.
What it assumes
Requires a synchronous Python callable and derives tool metadata and parameter schemas from its name, docstring, and signature.
What you can do after
Apply it via SimpleFunctionTool to expose a synchronous Python function as an LLM tool.
How it connects
Connects with BaseTool, JSON Schema, ToolCall, asynchronous tools, and Pydantic-based function tools.

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