liveBook · Manning

Abstract method

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

An abstract method is a method that concrete subclasses must implement before they can be instantiated.

An abstract method defines an obligation for subclasses: they must provide an implementation before instances can be created. In a tool interface, this enforces a consistent contract for tool metadata and execution. section 2.1.2

Listing 2.3 Defining BaseTool
# llm_agents_from_scratch/base/tool.py  #A
from abc import ABC, abstractmethod
from llm_agents_from_scratch.data_structures.tool import (
    ToolCall,  #B
    ToolCallResult,  #B
)
 
class BaseTool(ABC):
    """Base Tool Class."""
 
    @property  #C
    @abstractmethod
    def name(self) -> str:
        """Name of tool."""
 
 
    @property
    @abstractmethod  #D
    def description(self) -> str:
        """Description of what this tool does."""
 
    @property
    @abstractmethod
    def parameters_json_schema(self) -> dict[str, Any]:
        """JSON Schema for tool parameters."""
 
    @abstractmethod
    def __call__(
        self,
        tool_call: ToolCall,
        *args: Any,
        **kwargs: Any,
    ) -> ToolCallResult:
        """Execute the tool call."""  #E

The BaseTool definition marks three properties and __call__() as abstract, making the required interface explicit. section 2.1.2

A Hailstone tool

Hailstone subclasses BaseTool and implements its name, description, parameter schema, and __call__() method to perform a sequence step. section 2.1.2

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

How deep it goes
Explains abstract properties and methods, then demonstrates a subclass implementation without detailing abstract-method internals.
Examples
Uses a Hailstone tool that implements BaseTool and performs one step of the Hailstone sequence.
What you can do after
Build it from scratch by subclassing BaseTool and implementing its three properties and __call__().
How it connects
Connects abstract methods to abstract classes, inheritance, Python properties, and LLM tool calling.

Also explained in

Compare how 3 books explain abstract method →

Related concepts

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.