feat: Add adaptive tool execution analytics and intelligent retry system#281
Open
Rakshitha-Ireddi wants to merge 2 commits intosnap-stanford:mainfrom
Open
Conversation
- Implement comprehensive execution analytics tracking (success rate, latency, error patterns) - Add intelligent error classification system (timeout, network, validation, etc.) - Implement adaptive retry strategies with exponential/linear backoff - Add result caching system to avoid redundant tool calls - Integrate analytics into A1 agent with public API methods - Provide analytics summary and error analysis DataFrames - Support cache management and analytics reset functionality This feature enables: - Performance monitoring and optimization of tool usage - Automatic retry with context-aware strategies - Reduced redundant API calls through intelligent caching - Comprehensive error analysis for debugging and improvement
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adaptive Tool Execution Analytics and Intelligent Retry System
Authors
Overview
This PR introduces a comprehensive Adaptive Tool Execution Analytics and Intelligent Retry System to Biomni, providing advanced performance monitoring, error handling, and optimization capabilities for biomedical AI agent tool execution.
Key Features
1. Execution Analytics & Performance Tracking
2. Intelligent Error Classification
TIMEOUT: Execution timeoutsNETWORK: Network connectivity issuesVALIDATION: Input validation errorsRESOURCE: Resource exhaustion (memory, quota)PERMISSION: Access permission errorsNOT_FOUND: Resource not found errorsRATE_LIMIT: API rate limitingUNKNOWN: Unclassified errors3. Adaptive Retry Strategies
4. Intelligent Result Caching
Technical Implementation
New Module:
execution_analytics.pyExecutionAnalytics: Main analytics engine classToolAnalytics: Per-tool analytics data structureExecutionRecord: Individual execution recordErrorType: Error classification enumRetryStrategy: Retry strategy enumIntegration Points
get_execution_analytics(tool_name=None): Get analytics for tool(s)get_analytics_summary(): Get summary DataFrameget_error_analysis(): Get error analysis DataFrameclear_execution_cache(tool_name=None): Clear cached resultsreset_execution_analytics(): Reset all analyticsUsage Example
Benefits
Research
This feature addresses several gaps in the current Biomni architecture:
The adaptive retry system uses error classification to apply context-appropriate strategies, significantly improving reliability for biomedical research workflows that often involve network calls, API rate limits, and resource-intensive computations.
Testing
Files Changed
biomni/tool/execution_analytics.py(new): Core analytics and retry systembiomni/agent/a1.py: Integration of analytics systembiomni/tool/tool_registry.py: Optional analytics supportFuture Enhancements