Skip to content

feat: implement advanced tools framework with thread-safe hooks, caching and external execution#1218

Closed
github-actions[bot] wants to merge 1 commit intomainfrom
claude/pr-980-20260331-0926
Closed

feat: implement advanced tools framework with thread-safe hooks, caching and external execution#1218
github-actions[bot] wants to merge 1 commit intomainfrom
claude/pr-980-20260331-0926

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Summary

Implements the advanced tools framework that was originally in PR #980, with all critical issues fixed based on the comprehensive code reviews.

Key Features Implemented:

  • Enhanced @advanced_tool decorator with hooks, caching, and external execution support
  • Thread-safe global state using RLock for all shared data structures
  • Async-safe external handlers with proper sync/async detection and execution
  • Global hooks system with before/after execution hooks and priority levels
  • TTL-based caching with configurable key generation and conditional caching
  • External execution with handler registration and fallback mechanisms
  • Structured input validation with Field, InputGroup, Choice, Range, Pattern classes
  • Backward compatibility - doesn't interfere with existing tools system

Critical Issues Fixed:

  1. Thread Safety: All global variables now protected with threading.RLock()
  2. Async Handler Support: Proper detection and execution of async external handlers
  3. Decorator Bare Usage: Fixed @advanced_tool (no parentheses) vs @advanced_tool() support
  4. Parameter Names: Range constructor uses correct min_val/max_val parameters
  5. Lambda Signatures: Removed problematic lambda usage in favor of proper function calls

Test Coverage:

✅ 8/8 comprehensive tests passing:

  • Import functionality
  • Bare decorator usage
  • Parentheses decorator usage
  • Caching with TTL
  • External execution with handlers
  • Global hooks (before/after)
  • Input validation classes
  • Thread safety mechanisms

Architecture:

  • Follows AGENTS.md protocol-first design principles
  • Thread-safe and async-safe implementation
  • Minimal performance impact with lazy loading
  • Clean separation from existing tools system

🤖 Generated with Claude Code

…ing and external execution

- Add praisonaiagents/tools/advanced.py with enhanced tool decorators
- Support for hooks (before/after with priorities), TTL caching, external execution
- Thread-safe implementation using RLock for global state
- Async-safe external handler support
- Fix decorator bare usage pattern (@advanced_tool vs @advanced_tool())
- Fix parameter naming (Range uses min_val/max_val)
- Backward compatible with existing tools system
- Comprehensive test suite with 8/8 tests passing
- Addresses all critical issues from original PR #980 reviews

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
@MervinPraison
Copy link
Copy Markdown
Owner

Closing: auto-generated from closed issue #972. Superseded by #1214-#1217.

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Mar 31, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

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