Skip to content

Tool Registry and Management

For comprehensive documentation on the Tool Registry system, including architecture, usage patterns, and advanced features, see the Tools API Reference.

This page provides a summary of key concepts and links to detailed documentation.

Key Concepts

Tool Registry Architecture

  • Centralized Management: Single registry for all tool operations
  • Dynamic Discovery: Runtime tool registration and discovery
  • Type Safety: Strong typing with Pydantic validation
  • Performance Monitoring: Execution metrics and optimization

Tool Categories

DeepCritical organizes tools into logical categories for better organization and discovery:

Getting Started

Basic Usage

from deepresearch.src.utils.tool_registry import ToolRegistry

# Get the global registry
registry = ToolRegistry.get_instance()

# List available tools
tools = registry.list_tools()
print(f"Available tools: {list(tools.keys())}")

Tool Execution

# Execute a tool
result = registry.execute_tool("web_search", {
    "query": "machine learning",
    "num_results": 5
})

if result.success:
    print(f"Results: {result.data}")

Advanced Features

Tool Registration

from deepresearch.tools import ToolRunner, ToolSpec, ToolCategory

class MyTool(ToolRunner):
    def __init__(self):
        super().__init__(ToolSpec(
            name="my_tool",
            description="Custom analysis tool",
            category=ToolCategory.ANALYTICS,
            inputs={"data": "dict"},
            outputs={"result": "dict"}
        ))

# Register the tool
registry.register_tool(MyTool().get_spec(), MyTool())

Performance Monitoring

# Get tool performance metrics
metrics = registry.get_tool_metrics("web_search")
print(f"Average execution time: {metrics.avg_execution_time}s")
print(f"Success rate: {metrics.success_rate}")

Integration

With Agents

Tools are automatically available to agents through the registry system. See the Agents API for details on agent-tool integration.

With Workflows

Tools integrate seamlessly with the workflow system for complex multi-step operations. See the Code Execution Flow for workflow integration examples.

Best Practices

  1. Use Appropriate Categories: Choose the correct tool category for proper organization
  2. Handle Errors: Implement proper error handling in custom tools
  3. Performance Monitoring: Monitor tool performance and optimize as needed
  4. Documentation: Provide clear tool specifications and usage examples
  5. Testing: Thoroughly test tools before deployment