Skip to main content

Local Tools System

Register any Python function as an AI tool using the ToolRegistry.

How It Works

  1. Decorate any Python function with @tools.register_tool("tool_name")
  2. Type hints are automatically converted into JSON Schema for the LLM
  3. Docstrings become tool descriptions the LLM uses to decide when to call the tool
  4. Pass the ToolRegistry to your agent via local_tools=
Workspace files are enabled by default and reserve these built-in tool names: ls, read_file, write_file, edit_file, insert_file, delete_file, move_file, clear_files, glob, and grep. Use domain-specific names for application tools, such as fetch_invoice or query_knowledge_base.

Async Tools

Async functions work seamlessly:

Class-Based Tools

For more complex tools, use a class with a get_tool() method:
Register class-based tools:

Composing Local Tools

Use Local Tools for custom business logic, internal APIs, or Python functionality that belongs to your application. Use MCP for shared external services.