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 (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.
Parameter descriptions come from a Google-style 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.
Returns: List of (name, function) tuples for all capabilities

to_openai_function

Convert all capabilities to Tool objects with OpenAI-compatible schemas.
Returns: List of agentor.engine.tools.Tool 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

A small set of built-in tools can be referenced by string name:
The registry holds exactly two names today: get_weather and current_datetime. Any other string raises ValueError: Tool <name> not found. Every other built-in — Gmail, GitHub, Slack, and the rest — is a class you import and instantiate.

MCP Servers

The agent connects to the server for the duration of each run and closes it afterwards. See the MCP guide for details.

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 August 28, 2026