Skip to content

AgentTools System

The AgentTools system in the Multi-Agent Orchestrator provides a flexible framework for defining, building, and managing tools that agents can use. It consists of three main classes: AgentTool and AgentTools, which work together to enable tool-based interactions in the orchestrator.

Key Features

  • Support for multiple AI provider formats: Claude, Bedrock, OpenAI (coming soon)
  • Automatic function signature parsing
  • Type hint conversion to JSON schema
  • Flexible tool definition methods
  • Async/sync function handling
  • Built-in tool result formatting

AgentTool Class

The AgentTool class is the core component that represents a single tool definition. It can be created in multiple ways and supports various formats for different AI providers.

Creating a AgentTool

There are several ways to create a tool:

  1. Using the Constructor:
// TypeScript implementation coming soon
  1. Using the docstring:
// TypeScript implementation coming soon

Format Conversion

The AgentTool class can output its definition in different formats for various AI providers:

tool = AgentTool(
name="weather_tool",
description="Get current weather information",
func=get_weather,
enum_values={"units": ["celsius", "fahrenheit"]}
)
# For Claude
claude_format = tool.to_claude_format()
# For Bedrock
bedrock_format = tool.to_bedrock_format()
# For OpenAI
openai_format = tool.to_openai_format()

AgentTools Class

The AgentTools class manages multiple tool definitions and handles tool execution during agent interactions. It provides a unified interface for tool processing across different AI providers.

Creating and Using AgentTools

from multi_agent_orchestrator.utils import AgentTools, AgentTool
# Define your tools
weather_tool = AgentTool("weather", "Get weather info", get_weather)
# Create AgentTools instance
tools = AgentTools([weather_tool])
# Format tool with an agent
weather_agent = BedrockLLMAgent(BedrockLLMAgentOptions(
name="Weather Agent",
streaming=True,
description="Specialized agent for giving weather condition from a city.",
tool_config={
'tool': tools,
'toolMaxRecursions': 5,
},
))
# Use AgentTools class with an agent
weather_agent = BedrockLLMAgent(BedrockLLMAgentOptions(
name="Weather Agent",
streaming=True,
description="Specialized agent for giving weather condition from a city.",
tool_config={
'tool': AgentTools([weather_tool]),
'toolMaxRecursions': 5,
},
))

By using AgentTools, the logic of parsing the tool response from the Agent is hanlded directly by the class.

Using a AgentTool with an Agent

1. Definition

// TypeScript implementation coming soon

2. Adding AgentTool to Agent

Here is an example of how you can add AgentTools to your Agent

// TypeScript implementation coming soon

3. Overriding the tool hanlder

When you need more control over tool execution, you can implement a custom handler using the useToolHandler option in your tool_config. This handler lets you:

  • Intercept and process the tool invocation before execution
  • Parse the tool block directly from your Agent’s output
  • Generate and format custom tool responses
// TypeScript implementation coming soon

This approach provides flexibility when you need to extend the default tool behavior with custom logic, validation, or response formatting. The handler receives the raw tool block text and is responsible for all aspects of tool execution and response generation.

Best Practices

  1. Function Documentation: Always provide clear docstrings for functions used in tools. The system uses these for generating descriptions and parameter documentation.

  2. Type Hints: Use Python type hints in your tool functions. These are automatically converted to appropriate JSON schema types.

  3. Error Handling: Implement proper error handling in your tool functions. AgentTool execution errors are automatically captured and formatted appropriately.

  4. Provider Compatibility: When creating tools, consider the formatting requirements of different AI providers if you plan to use the tools across multiple provider types.

  5. AgentTool Naming: Use clear, descriptive names for your tools and maintain consistency in naming conventions across your application.

By following these guidelines and leveraging the AgentTools system effectively, you can create powerful and flexible tool-based interactions in your Multi-Agent Orchestrator implementation.

Next Steps

To continue learning about AgentTools in the Multi-Agent Orchestrator System, head over to our examples in Github