The tool system provides agents with capabilities to perform actions beyond generating text. Tools can retrieve information, perform calculations, interact with external systems, or execute code. This specification defines how tools are integrated and used within the Flock framework.
- Tools must be callable functions or methods
- Tools must accept standard Python types as inputs
- Tools must return JSON-serializable outputs
- Tools should include proper docstrings for agent instruction
- Tools should handle errors gracefully
Tools can be registered in two ways:
- Through agent definition:
tools=[tool1, tool2]
- Through Flock registration:
flock.add_tool("tool_name", tool_function)
Tools attached to an agent are:
- Registered in the global registry
- Made available to the agent during evaluation
- Formatted appropriately for the model to understand their capabilities
The evaluator is responsible for:
- Formatting tools for model consumption
- Detecting tool invocation in model outputs
- Executing tools with appropriate parameters
- Formatting tool results for continued model interaction
- Web search tools
- Code evaluation tools
- System information tools
- File manipulation tools
- Data analysis tools
- API interaction tools
- Database tools
- Visualization tools
- Agent provides tools list during initialization
- Evaluator formats tools as function descriptions for the model
- Model generates output that may include tool invocation
- Evaluator parses the tool invocation and parameters
- Evaluator executes the tool with parsed parameters
- Tool result is formatted and provided back to the model
- Model continues generation with tool results available
- Final model output is returned as agent result
-
Flexibility:
- Support for any callable function
- No special base classes required
- Dynamic addition of tools possible
-
Safety:
- Tools should have clear boundaries
- Error handling to prevent failures
- Input validation for security
-
Discoverability:
- Clear documentation for agent understanding
- Consistent interface patterns
- Self-describing capabilities
-
Performance:
- Efficient execution
- Proper handling of async tools
- Support for caching tool results
- Tools must work with different model providers
- Tools must handle both synchronous and asynchronous execution
- Tools should provide clear error messages
- Tools should be testable in isolation
- Complex tools should be composable from simpler tools