Skip to content

feat: Add tool health check and warmup functionality#344

Open
SHINING2024 wants to merge 1 commit into
calesthio:mainfrom
SHINING2024:feat/tool-health-check-warmup
Open

feat: Add tool health check and warmup functionality#344
SHINING2024 wants to merge 1 commit into
calesthio:mainfrom
SHINING2024:feat/tool-health-check-warmup

Conversation

@SHINING2024

Copy link
Copy Markdown

Overview

Add comprehensive tool health check and warmup functionality to assess tool availability and prepare tools before first use.

Motivation

  • No health assessment: Currently, hard to know if tools are working properly
  • Slow first runs: Tools with heavy initialization (models, connections) have slow first execution
  • Better reliability: Proactive health checks prevent surprises during production
  • System-wide visibility: Health report gives overview of all tool statuses

Technical Implementation

New in tools/base_tool.py:

  • ToolHealth enum with HEALTHY, DEGRADED, UNHEALTHY statuses
  • health_check() - Performs health assessment, returns status + message
  • warmup() - Optional method for tool initialization/preloading
  • Fixed indentation of validation methods

New in tools/tool_registry.py:

  • health_report() - Generates system-wide health report
  • get_healthy_tools() - Returns list of only healthy tools

Features

✅ Health check status for individual tools
✅ System-wide health report
✅ Warmup/hook for tool initialization
✅ No breaking changes
✅ Backward compatible

Usage Example

# Check health of a single tool
health, message = tool.health_check()
print(f"Tool health: {health}")

# Get system-wide health report
registry = ToolRegistry()
registry.discover()
report = registry.health_report()

# Get only healthy tools
healthy_tools = registry.get_healthy_tools()

# Implement warmup in a subclass
class MyTool(BaseTool):
    def warmup(self):
        # Preload model, establish connections, etc.
        self.model = load_model()

Testing

  • ✅ Verify health check for available tools
  • ✅ Verify health check for unavailable tools
  • ✅ Test health report generation
  • ✅ Test get_healthy_tools filtering

- Add validate_inputs() method with jsonschema validation
- Add validate_outputs() method for output validation
- Add execute_safe() wrapper for validation + error handling
- Add ValidationError exception class
- Optional jsonschema dependency with graceful fallback
- No breaking changes to existing code
@SHINING2024 SHINING2024 requested a review from calesthio as a code owner July 10, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant