Human Approval System
The approval module provides a comprehensive human-in-the-loop approval system for dangerous tool operations, ensuring safety and control over high-risk agent actions.Overview
The approval system allows you to:- Require human approval before executing dangerous operations
- Categorize tools by risk level (critical, high, medium, low)
- Implement custom approval logic and policies
- Modify tool arguments before execution
- Track approved operations to avoid duplicate prompts
Quick Start
Risk Levels
Critical Risk
Operations that could cause severe damage:execute_command
- Arbitrary command executionexecute_code
- Code executionkill_process
- Process termination
High Risk
Operations that modify system state:write_file
- File creation/modificationdelete_file
- File deletionmove_file
- File relocationcopy_file
- File duplicationexecute_query
- Database modifications
Medium Risk
Operations with moderate impact:evaluate
- Expression evaluationcrawl
- Web crawlingscrape_page
- Web scraping
Low Risk
Operations with minimal impact (example category)Using the Approval Decorator
Basic Usage
Async Functions
Custom Approval Callbacks
Console Approval (Default)
The default callback shows a formatted prompt in the console:Automated Policies
GUI Integration
Managing Approval Requirements
Adding Requirements
Removing Requirements
Checking Requirements
Integration with Agents
Setting Custom Callbacks
Context Preservation
The approval system tracks approved operations within the same context:Complete Example
Best Practices
- Risk Assessment - Carefully categorize tools by actual risk level
- User Experience - Provide clear information about what will be executed
- Logging - Always log approval decisions for audit trails
- Timeout Handling - Consider adding timeouts for approval prompts
- Batch Operations - Group related approvals to reduce prompt fatigue
- Emergency Override - Implement emergency approval bypass for critical situations
- Testing - Test approval flows thoroughly before production deployment