Building Tools
Using BaseTool
ExtendBaseTool and implement __invoke(). The parameter schema is auto-generated from the method signature:
Using FunctionTool
Wrap any callable without creating a class:Accessing Agent State
ImplementCanAccessAgentState (already included in BaseTool) to receive the current agent state:
The ToolInterface
All tools implementToolInterface:
use()- execute the tool, returnsResult(success or failure)toToolSchema()- OpenAI-compatible function schema for the LLMmetadata()- lightweight info for tool discoveryinstructions()- full specification for detailed tool documentation