Local Tools System
Register any Python function as an AI tool using the ToolRegistry.
How It Works
- Decorate any Python function with
@tools.register_tool("tool_name")
- Type hints are automatically converted into JSON Schema for the LLM
- Docstrings become tool descriptions the LLM uses to decide when to call the tool
- 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 functions work seamlessly:
For more complex tools, use a class with a get_tool() method:
Register class-based tools:
Use Local Tools for custom business logic, internal APIs, or Python functionality
that belongs to your application. Use MCP for shared external services.