Overview
The Human Approval System provides a minimal yet powerful human-in-the-loop framework for dangerous tool operations in PraisonAI Agents. It extends the existing callback system to require human approval before executing high-risk tools, ensuring safety and control over critical operations.Quick Start
1
Import the approval system
2
Create a tool with approval requirement
3
Use the tool with an agent
Core Concepts
Risk Levels
The approval system categorises tools into four risk levels:Critical Risk
Operations that can severely impact the system
- System command execution
- Process termination
- Code execution
execute_command, kill_process, execute_codeHigh Risk
Operations that modify system state
- File writing/deletion
- Database modifications
- File system operations
write_file, delete_file, execute_queryMedium Risk
Operations with moderate impact
- Data evaluation
- Web crawling
- External API calls
evaluate, crawl, scrape_pageLow Risk
Read-only or minimal impact operations
- File reading
- Data queries
- Information retrieval
read_file, list_filesApproval Flow Lifecycle
- Tool Execution Request: Agent attempts to execute a tool
- Approval Check: System checks if tool requires approval
- Context Verification: Checks if already approved in current context
- User Prompt: Displays tool details and requests approval
- Decision Processing: Handles approval, denial, or modification
- Execution: Tool executes with approved parameters
API Reference
Decorators
@require_approval
Decorator to mark a tool as requiring human approval.
risk_level: Risk level of the tool (“critical”, “high”, “medium”, “low”)
Classes
ApprovalDecision
Result of an approval request.
approved: Whether the operation was approvedmodified_args: Modified arguments to merge with originalreason: Reason for approval/denial
Functions
set_approval_callback
Set a custom approval callback function.
callback_fn: Function that accepts (function_name, arguments, risk_level) and returns ApprovalDecision
add_approval_requirement
Dynamically add approval requirement for a tool.
remove_approval_requirement
Remove approval requirement for a tool.
is_approval_required
Check if a tool requires approval.
Usage Examples
Basic Usage with Default Console Approval
- Shell Tools
- Custom Tool
Custom Approval Callback
Async Support
Runtime Configuration
Integration with Agents
Automatic Integration
The approval system automatically integrates with any tool used by agents:- Tool Detection: When an agent attempts to use a tool, the system checks if approval is required
- Context Management: Approved tools are tracked per execution context
- Seamless Flow: Agents continue execution after approval without additional configuration
Best Practices
Security Best Practices
- Always require approval for system commands
- Use appropriate risk levels for tools
- Validate and sanitise inputs before execution
- Log all approval decisions for audit
User Experience
- Provide clear descriptions in approval prompts
- Group related operations to minimise prompts
- Use custom callbacks for automated policies
- Consider batch approvals for repetitive tasks
Advanced Features
Context-Aware Approvals
The system tracks approved operations within execution contexts:Approval Context Management
Default Dangerous Tools
The system comes with pre-configured dangerous tools:Console Approval Interface
The default console approval interface provides:- Colour-coded risk levels
- Clear parameter display
- Truncation of long values
- Keyboard interrupt handling
- Rich formatting with panels
Error Handling
The approval system handles various error scenarios:- Permission Denied
- Callback Errors
- Async Context
Security Considerations
Summary
The Human Approval System provides essential safety controls for PraisonAI Agents: ✅ Flexible Risk Management - Categorise and control tools by risk level✅ Seamless Integration - Works automatically with existing agents and tools
✅ Customisable Callbacks - Implement custom approval logic and policies
✅ Async Support - Full support for asynchronous operations
✅ Runtime Configuration - Dynamically adjust approval requirements Use this system whenever agents interact with:
- System commands and shell operations
- File system modifications
- Database operations
- External APIs with side effects
- Any potentially dangerous operations

