Skip to main content

Overview

The Tool Override system allows loading custom tools from Python files, modules, and directories at runtime. This enables extending PraisonAI with custom functionality without modifying the core package.

Python API

ToolOverrideLoader

Context Manager Pattern

Use the context manager for temporary tool overrides:

Creating Tool Registry with Overrides

Default Custom Tool Directories

PraisonAI loads custom tools from two distinct groups. Autoload-gated files load only when PRAISONAI_ALLOW_TEMPLATE_TOOLS=1: Default custom dirs are always scanned when include_defaults=True:
Implicit tools.py autoload from the current working directory is disabled by default. To enable this legacy behavior, set PRAISONAI_ALLOW_TEMPLATE_TOOLS=1. For new projects, prefer explicit override_files or override_dirs configuration.

What the wrapper does not own

create_tool_registry_with_overrides() used to re-implement praisonai-tools package discovery and a praisonaiagents built-ins hook of its own. As of PraisonAI#3122 those are handled only by the canonical ToolResolver, so:
  • You do not need to install praisonai-tools differentlyresolve_tools() still finds it via the canonical resolver.
  • A tool that resolved through the wrapper’s old package-discovery block still resolves — just one implementation away, in the resolver instead.
  • The template/CWD tools.py autoload stays in the wrapper on purpose. It carries the PRAISONAI_ALLOW_TEMPLATE_TOOLS gate (with a skip-on-error contract and explicit-template-dir-outside-CWD support) that the resolver’s PRAISONAI_ALLOW_LOCAL_TOOLS + CWD-boundary gate does not provide.

Discovering Tools Without Execution

Discover tool names without importing/executing code:

Security

Local Paths Only

Remote URLs are rejected by default:

Safe Defaults

  • Only local file paths are allowed
  • Implicit tools.py autoload from CWD or template directories is disabled by default — opt in with PRAISONAI_ALLOW_TEMPLATE_TOOLS=1
  • Discovery uses AST parsing (no execution)
  • Context manager ensures cleanup

Opting in to implicit tools.py autoload

For legacy workflows that depend on automatic tools.py loading:
Accepted truthy values: 1, true, yes, on (case-insensitive, whitespace-stripped) Recommended approach: Use explicit override_files, override_dirs, or tools_sources configuration instead of relying on implicit autoload. See Security Environment Variables for more details.

Custom Tool File Format

Create a Python file with functions: