Tools
Give agents new abilities with custom tools.
A tool is a Python function that your agents can use to accomplish tasks. Tools extend an agent’s capabilities beyond their built-in knowledge and abilities, allowing them to interact with external systems, perform calculations, or access specific information.
Tools can be:
- Simple utility functions for common operations
- Complex data processing operations
- API calls to external services
- File system operations
- Database queries
- System commands
- Custom business logic
Here’s a basic example of a tool for rolling dice:
Creating Tools
Any Python function can be used as a tool. The function’s name, docstring, and type hints help agents understand what the tool does and how to use it:
Using Tools
Tools can be provided to tasks or agents. When a tool is provided to a task, any agent working on that task will have access to the tool. When a tool is provided to an agent, the agent can use the tool in any task it is assigned to:
Common Use Cases
Tools are particularly useful for:
- Accessing external APIs or services
- Performing calculations or data processing
- File operations and data manipulation
- Database queries and updates
- System interactions
- Custom business logic
- Integration with existing code