Assign Tools to Templates
Step-by-step guide to assigning and configuring tools in templates
Wire built-in or custom tools into template manifests so agents can call them at runtime.
from praisonaiagents import Agent, tool
@tool
def status_lookup(id: str) -> str:
"""Return item status."""
return f"Status for {id}: ready"
agent = Agent(name="Template Agent", tools=[status_lookup])
agent.start("Check status for item 99.")The user declares tools in YAML, assigns them to roles, and runs the template with those capabilities.
How It Works
How to Assign Built-in Tools
- List Available Built-in Tools
bash praisonai tools list - Add to TEMPLATE.yaml
yaml # TEMPLATE.yaml name: my-template version: "1.0.0" requires: tools: - internet_search - shell_tool - file_read_tool - Assign to Agents
yaml # agents.yaml roles: researcher: role: Research Agent tools: - internet_search executor: role: Executor Agent tools: - shell_tool - file_read_tool
How to Assign Custom Tools from tools.py
- Create tools.py
python # tools.py def analyze_data(data: str) -> dict: """Analyze input data. Args: data: Data to analyze Returns: Analysis results """ return {"analysis": "complete", "data": data} - Assign to Agent
yaml # agents.yaml roles: analyst: role: Data Analyst tools: - analyze_data tasks: analyze: description: "Analyze the provided data" - Run Template
bash praisonai templates run ./my-template
How to Assign Tools from External Sources
- Add tools_sources
yaml # TEMPLATE.yaml requires: tools_sources: - praisonai_tools.video - ./extra_tools.py - Assign External Tools
yaml # agents.yaml roles: video_editor: role: Video Editor tools: - shell_tool tasks: edit: description: | Use python -m praisonai_tools.video to edit videos
How to Assign Tools Dynamically with Python
- Load Template
python from praisonai.templates.loader import TemplateLoader loader = TemplateLoader() template = loader.load_template("my-template") - Create Custom Tools
python def custom_tool(input: str) -> str: """Custom processing tool.""" return f"Processed: {input}" - Run with Additional Tools
python result = template.run( task="Process data", additional_tools=[custom_tool] )
Best Practices
Assign only the tools a role needs
Listing the minimum tool set per role keeps the agent focused and avoids unintended actions.
Use descriptive tool names
Clear names help both the model and the reader understand what each assigned tool does at a glance.
Verify tools resolve before assigning
Run praisonai tools list (or doctor) so every name in the manifest actually resolves at runtime.
Group related tools together
Keeping related tools on the same role makes recipes easier to reason about and maintain.