Base Tool • AI Agent SDK
BaseTool: Abstract base class for all PraisonAI tools.
BaseTool
Defined in the base module.
AI Agent
Abstract base class for all PraisonAI tools.
Subclass this to create custom tools that can be:
- Used directly by agents
- Distributed as pip-installable plugins
- Auto-discovered via entry_points
Attributes: name: Unique identifier for the tool description: Human-readable description (used by LLM) version: Tool version string (default: “1.0.0”) parameters: JSON Schema for parameters (auto-generated if not provided)
Constructor
OptionalNo description available.
Properties
strNo description available.
strNo description available.
strNo description available.
OptionalNo description available.
Optional[bool]No description available.
OptionalNo description available.
OptionalNo description available.
Methods
Validate a tool class before instantiation.
run()Execute the tool with given arguments.
to_model_output()Optional hook returning a compact, model-facing view of `result`.
Execute tool with error handling, returning ToolResult.
get_schema()Get OpenAI-compatible function schema for this tool.
validate()Validate the tool configuration.
validate_schema_roundtrip()Validate that schema can round-trip through OpenAI-style serialization.
Usage
class WeatherTool(BaseTool):
name = "get_weather"
description = "Get current weather for a location"
def run(self, location: str, units: str = "celsius") -> dict:
# Implementation here
return {"temp": 22, "condition": "sunny"}Source
View on GitHubpraisonaiagents/tools/base.py at line 179