Overview
Agentor provides multiple ways to create tools that agents can use to interact with external systems, APIs, and data sources. Tools enable agents to perform actions beyond text generation.Tool Decorators
@tool
The@tool decorator creates dual-mode tools usable by both Agentor agents and the LLM client.
name(str): Optional custom tool name (defaults to function name)description(str): Optional description (defaults to docstring)
@function_tool
The@function_tool decorator creates tools compatible with the OpenAI function calling format.
name_override(str): Optional custom name for the tool (defaults to the function name)description_override(str): Optional description (defaults to the docstring summary)
Options the decorator accepted before 0.1.0 —
strict_mode, failure_error_function, use_docstring_info, and the rest — are still accepted and ignored, so existing tool definitions keep importing unchanged.Args: block in the docstring. They are worth writing: without them the model sees only a type name and guesses more.
Example:
BaseTool Class
BaseTool is the base class for creating custom tools with multiple capabilities.
Basic Usage
Class Definition
Methods
list_capabilities
List all capabilities of the tool.to_openai_function
Convert all capabilities toTool objects with OpenAI-compatible schemas.
agentor.engine.tools.Tool objects
json_schema
Convert all capabilities to JSON Schema format.serve
Serve the tool as an MCP (Model Context Protocol) server.name(str): Optional server name (defaults to tool name)port(int): Port to serve on (default: 8000)
from_function
Create a BaseTool from a standalone function.@capability Decorator
Mark a method as a tool capability that agents can invoke.Using Tools with Agents
Function Tools
BaseTool Instances
Tool Registry
A small set of built-in tools can be referenced by string name:MCP Servers
Built-in Tools
Agentor includes several built-in tools:Calculator Tool
Weather Tool
Tool Examples
Simple Function Tool
Multi-Capability Tool
Tool with State
Tool from Function
Best Practices
- Clear Descriptions: Always provide clear docstrings - they become tool descriptions for the LLM
- Type Hints: Use type hints for all parameters and return values
- Error Handling: Handle errors gracefully within tool functions
- Focused Tools: Keep tools focused on specific tasks
- Idempotent Operations: Make tools safe to retry when possible
- Documentation: Document expected inputs and outputs
