Skip to main content
Tools are functions that agents invoke to take actions and gather information. In each iteration of an agent’s loop, the model returns the next steps as tool calls. The agent invokes these tools, gathers their responses, and continues its loop.

Python Functions as Tools

Wrap Python functions to create tools. Any function becomes a tool that your agent invokes.
images/main/main.py
images/main/Dockerfile
autonomy.yaml
The Tool() wrapper converts your function into a tool specification. Docstrings become tool descriptions that help the model understand when to use the tool. Type hints define parameter types (converted to JSON schema). Both sync and async functions are supported.

MCP Tools

Model Context Protocol (MCP) provides agents with tools from external servers. MCP servers expose standardized interfaces to services like web search, databases, and APIs.

Configure MCP Server

Define MCP servers in your autonomy.yaml:
autonomy.yaml
Store your API key in secrets.yaml:
secrets.yaml

Use MCP Tools

Reference MCP server tools using McpTool():
images/main/main.py
images/main/Dockerfile
The agent will use the brave_web_search tool to find current information and incorporate it into its response.

Built-in Tools

Agents have access to several built-in tools:

Time Tools

Always available without configuration:
  • get_current_time_utc - Get current time in UTC timezone
  • get_current_time - Get current time in a specific timezone (e.g., “America/New_York”)

Human-in-the-Loop

Agents pause and request user input during interactive conversations. See Human-in-the-loop for complete documentation on the ask_user_for_input tool.

Additional Built-in Tools

  • Filesystem tools - Read, write, and search files. See Filesystem Tools.
  • Subagent tools - Delegate work to specialized sub-agents. See Subagents.

Tool Factories (Advanced)

Tool Factories create scope-aware tools that are instantiated per-user, per-conversation, or per-agent. This is essential for multi-tenant applications where tools need isolated resources.

When to Use Tool Factories

Use tool factories when:
  • Tools need per-user or per-conversation state
  • Tools access user-specific resources (databases, files, APIs)
  • Tools require tenant isolation for security
  • Static tool instances can’t be shared safely

Implement ToolFactory Protocol

Create a class that implements the create_tools() method:
The agent framework detects the factory implements ToolFactory. For each conversation, the framework calls create_tools(scope, conversation, agent_name). You create tools with proper isolation based on the provided context. Each user/conversation gets their own tool instances with isolated resources.

Factory vs Static Tools

Static tools (using Tool(func)):
  • Same instance shared across all users and conversations
  • Suitable for stateless operations (time, calculations, read-only APIs)
  • Simple and efficient
Factory tools (using ToolFactory):
  • New instances created per-user/per-conversation
  • Suitable for stateful operations (databases, filesystems, user-specific APIs)
  • Provides tenant isolation and security

How Tools Work

Tool Specification

Tools are described to models using JSON schema format:
The Tool() wrapper automatically generates this specification from:
  • Function name → tool name
  • Docstring → description
  • Type hints → parameter types
  • Required vs optional parameters

Type Coercion

The framework coerces JSON values to match Python type hints:
Supported coercions:
  • strint, float, bool
  • String booleans: “true”/“false”, “yes”/“no”, “1”/“0”
  • Numbers to strings
  • Empty/null handling

Error Handling

Tool errors are captured and returned as strings to the model:
The agent sees the error and decides how to respond—retry with different parameters, ask for clarification, or explain the problem to the user.

Size Limits

  • JSON arguments: 1MB maximum
  • Tool responses: No hard limit, but keep responses concise for model context efficiency