Skip to main content
Agents can request human approval before taking sensitive actions.

Quick Start

1

Enable Approval

import { Agent } from 'praisonai';

const agent = new Agent({
  instructions: 'You can execute commands',
  approval: true  // Requires approval for all tool calls
});

// Agent will pause and ask for approval
await agent.chat('Delete the temp files');
// → "Approve action: delete_files? [y/n]"
2

Auto-Approve Patterns

const agent = new Agent({
  approval: {
    autoApprove: ['read_*', 'search_*'],  // Safe patterns
    autoDeny: ['delete_*', 'rm_*']        // Dangerous patterns
  }
});

User Interaction Flow


Configuration Levels

// Level 1: Bool - Require approval for everything
const agent = new Agent({
  approval: true
});

// Level 2: Array - Require for specific tools
const agent = new Agent({
  approval: ['delete', 'execute', 'send']
});

// Level 3: Dict - Auto-approve/deny patterns
const agent = new Agent({
  approval: {
    autoApprove: ['read_*', 'list_*'],
    autoDeny: ['delete_*'],
    timeout: 60000
  }
});

// Level 4: Instance - Custom handler
import { ApprovalManager } from 'praisonai';

const approver = new ApprovalManager({
  handler: async (request) => {
    return await askUserViaSlack(request);
  }
});

Approval Options

OptionDescription
autoApprovePatterns to auto-approve
autoDenyPatterns to auto-deny
timeoutTime to wait for response (ms)
handlerCustom approval function

API Reference

ApprovalCallbackConfig

Complete configuration options

Best Practices

Reading data is usually safe to auto-approve.
Block delete, execute, and similar risky operations.
Default to 60 seconds; adjust based on your workflow.