Plugin System
PraisonAI TypeScript provides a powerful plugin system that allows you to create custom tools and extend agent capabilities. This matches the Python SDK’s extensibility pattern.Overview
There are three ways to create custom tools:- Class-based - Extend
BaseToolfor complex tools with state - Function-based - Use
createTool()for simple inline tools - Decorator-style - Use
tool()function for quick tool creation
BaseTool Class
TheBaseTool abstract class is the foundation for creating custom tools:
BaseTool Methods
| Method | Description |
|---|---|
run(params) | Execute the tool (must implement) |
execute(params) | Alias for run() |
safeRun(params) | Execute with error handling, returns ToolResult |
getSchema() | Get OpenAI-compatible function schema |
validate() | Validate tool configuration |
Safe Execution
UsesafeRun() for error handling:
createTool Function
For simple tools, use thecreateTool() helper:
tool() Function
Thetool() function provides a decorator-style approach:
Tool Registry
Register and manage tools withToolRegistry:
Using Tools with Agents
Pass tools to agents for function calling:Creating NPM Plugins
You can distribute tools as npm packages:Tool Validation
Validate tools before use:OpenAI Schema Generation
Get OpenAI-compatible schemas for any tool:Best Practices
- Clear descriptions - Write detailed descriptions for LLM understanding
- Type safety - Use TypeScript generics for input/output types
- Error handling - Use
safeRun()or try/catch inrun() - Validation - Define
parametersschema for input validation - Versioning - Set
versionfor tracking tool changes - Testing - Write unit tests for your tools
Example: Complete Plugin
Related
- Tools - Built-in tools
- Custom Tools - More examples
- Agents - Using tools with agents

