A tool registry organizes an agent’s tools for lookup when handling tool-call requests. In an LLM agent, it works alongside the tool set and the backbone LLM. section 4.1
Register tools by name:
- Adding a tool stores it in the registry; adding another tool with the same name raises an error. section 4.1.2
Adding a simple tool
An agent can register a function-backed tool that adds one to an integer. section 4.1.2
Listing 4.4 Implementing LLMAgent: add_tool()
# llm_agents_from_scratch/agent/llm_agent.py
… #A
from llm_agents_from_scratch.base.tool import AsyncBaseTool, Tool
class LLMAgent:
… #B
def add_tool(self, tool: Tool) -> Self:
"""Add a tool to the agents tool set.
NOTE: Supports fluent style for convenience.
Args:
tool (Tool): The tool to equip the LLM agent.
"""
if tool.name in self.tools_registry:
raise LLMAgentError( #C
f"Tool with name {tool.name} already exists.",
)
self.tools_registry[tool.name] = tool
return selfSee the add_tool() implementation, including its duplicate-name check and fluent return. section 4.1.2



