Skip to main content

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.
Signature:
Parameters:
  • name (str): Optional custom tool name (defaults to function name)
  • description (str): Optional description (defaults to docstring)
Example with custom name:

@function_tool

The @function_tool decorator creates tools compatible with the OpenAI function calling format.
Parameters:
  • name_override (str): Optional custom name for the tool
  • strict_mode (bool): Enable strict parameter validation (default: True)
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.
Returns: List of (name, function) tuples for all capabilities

to_openai_function

Convert all capabilities to OpenAI-compatible FunctionTools.
Returns: List of FunctionTool objects

json_schema

Convert all capabilities to JSON Schema format.
Returns: List of tool schemas

serve

Serve the tool as an MCP (Model Context Protocol) server.
Parameters:
  • name (str): Optional server name (defaults to tool name)
  • port (int): Port to serve on (default: 8000)
Example:

from_function

Create a BaseTool from a standalone function.
Example:

@capability Decorator

Mark a method as a tool capability that agents can invoke.

Using Tools with Agents

Function Tools

BaseTool Instances

Tool Registry

Tools can be registered and 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

  1. Clear Descriptions: Always provide clear docstrings - they become tool descriptions for the LLM
  2. Type Hints: Use type hints for all parameters and return values
  3. Error Handling: Handle errors gracefully within tool functions
  4. Focused Tools: Keep tools focused on specific tasks
  5. Idempotent Operations: Make tools safe to retry when possible
  6. Documentation: Document expected inputs and outputs
  • Agentor - Using tools with agents
  • LLM - Direct LLM usage with tools
Last modified on May 5, 2026