Skip to main content

Overview

PraisonAI automatically discovers tools from multiple sources. The show-sources command displays all configured tool sources and their resolution order.

Tool Resolution Order

Tools are resolved in the following order (highest priority first):
PrioritySourceDescription
1Override filesExplicit --tools CLI flag
2Override directoriesExplicit --tools-dir CLI flag
3Template tools_sourcesFrom TEMPLATE.yaml
4Template-local tools.pyIn template directory
5Current directory tools.py./tools.py in working directory
6Default custom dirs~/.praisonai/tools, ~/.config/praison/tools
7Package discoverypraisonai_tools if installed
8Built-in toolspraisonaiagents.tools.TOOL_MAPPINGS

Code Usage

from pathlib import Path

# Tool sources resolution order
sources = {
    "built_in": "praisonaiagents.tools.TOOL_MAPPINGS",
    "package_discovery": ["praisonai_tools"],
    "default_dirs": [
        "~/.praisonai/tools",
        "~/.config/praison/tools",
    ],
    "cwd_tools_py": "./tools.py",  # Current working directory
}

# Check if tools.py exists in current directory
cwd_tools_py = Path.cwd() / "tools.py"
if cwd_tools_py.exists():
    print(f"Found local tools.py: {cwd_tools_py}")

# Check template-specific sources
from praisonai.templates.loader import TemplateLoader

loader = TemplateLoader()
template = loader.load_template("ai-video-editor")

if template.requires:
    tools_sources = template.requires.get("tools_sources", [])
    print(f"Template tools_sources: {tools_sources}")

# Check for template-local tools.py
tools_py = Path(template.path) / "tools.py"
if tools_py.exists():
    print(f"Template local tools.py: {tools_py}")

Automatic tools.py Loading

If a tools.py file exists in your current working directory, it will be automatically loaded when running templates or agents. This is useful for project-specific tools:
# tools.py (in your project directory)
def my_custom_tool(query: str) -> str:
    """My custom tool for this project."""
    return f"Processing: {query}"

def another_tool(data: dict) -> dict:
    """Another project-specific tool."""
    return {"result": data}
These tools will be available to your agents without any additional configuration.