Overview
Custom tools allow you to extend your agent’s capabilities by writing Python functions that can interact with external APIs, process data, or perform specialized tasks.Tool Signature
Every custom tool must follow this standard signature:Parameters
Session variables passed to the tool. These can include:
- Variables from agent capture variables
- Variables returned by other tools in their
capture_variablesdictionary - Variables from the API payload that triggered the workflow
inputs.get("variable_name")Environment-specific secrets and configuration values defined in the Environment page, such as:
- API keys
- Authentication tokens
- Database credentials
env_variables.get("API_KEY")Return Value
Your tool must return a dictionary with two keys:The primary result of your tool’s execution. The agent uses this value to understand what the tool accomplished.
A dictionary of variables to store in the session. These can be accessed by other agents or tools later in the workflow.
Creating a Custom Tool
1. Write Your Python Function
Navigate to the Custom Tools section and create a new tool with your Python code.2. Add a Description
3. Example Tool
Here’s a complete example of an inventory management tool:inventory_tool.py
Best Practices
Environment Management
Environment Management
- Dev: Test new tools and changes
- UAT: Validate with staging data
- Prod: Deploy stable, tested versions
Version Control
Version Control
- Add version numbers to your tools
- Include release notes describing changes
- Keep previous versions available for rollback
Error Handling
Error Handling
- Always validate inputs before processing
- Use try-except blocks for external API calls
- Return meaningful error messages in the output
- Store errors in output dict or capture variables dict for debugging
Testing
Testing
- Test tools in Dev environment first
- Validate with edge cases and invalid inputs
- Monitor tool performance and errors in production
- Check capture_variables are stored correctly