A minimal Python framework for registering, managing, and invoking tool functions for LLM (Large Language Model) interactions and agentic AI.
- Singleton tool registry for dynamic function registration and lookup
- Decorator for easy tool registration
- Automatic metadata generation for tool functions (for LLM tool use)
- Unified tool invocation interface with argument parsing
- Custom exception for missing tools
- Type hints throughout for clarity and static analysis
- Unit tests and linting included
- Clone the repository:
git clone https://github.com/simonharris/agent_toolbelt.git cd agent_toolbelt - Create a virtual environment and install dependencies:
make install
from framework import register_tool
@register_tool('add')
def add(a: str, b: str) -> str:
"""Add two numbers as strings and return the sum as a string."""
return str(int(a) + int(b))from framework import run_tool
import json
result = run_tool({
"name": "add",
"arguments": json.dumps({"a": "2", "b": "3"})
})
print(result) # Output: '5'from framework import generate_tool_metadata, TOOL_REGISTRY
meta = generate_tool_metadata(TOOL_REGISTRY['add'])
print(meta)You can use the generated tool metadata as part of your LLM API call (e.g., OpenAI, Anthropic, etc.).
# Example: Using with OpenAI's chat API
from framework import get_tools
tools = get_tools() # List of tool metadata dicts
response = client.chat.completions.create(
model=MODEL,
messages=messages,
tools=tools, # Pass the tool metadata here
tool_choice="auto"
)This allows the LLM to see and use your registered tools automatically during the conversation.
Run all tests with:
make test- Check PEP8/style issues:
make lint
- See a code quality score:
make pylint
MIT