> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Approval

> Human oversight for agent actions

Agents can request human approval before taking sensitive actions.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Approval Flow"
        A[🤖 Agent] --> B[⚠️ Request]
        B --> C[👤 Human]
        C -->|approve| D[✅ Execute]
        C -->|deny| E[❌ Block]
    end
    
    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef human fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef result fill:#10B981,stroke:#7C90A0,color:#fff
    classDef blocked fill:#8B0000,stroke:#7C90A0,color:#fff
    
    class A,B agent
    class C human
    class D result
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff
    class E blocked
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff
```

## Quick Start

<Steps>
  <Step title="Simple Usage">
    ```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    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]"
    ```
  </Step>

  <Step title="With Configuration">
    ```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    const agent = new Agent({
      approval: {
        autoApprove: ['read_*', 'search_*'],  // Safe patterns
        autoDeny: ['delete_*', 'rm_*']        // Dangerous patterns
      }
    });
    ```
  </Step>
</Steps>

***

## User Interaction Flow

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Tool
    
    User->>Agent: "Delete old files"
    Agent->>Agent: Detect sensitive action
    Agent->>User: "Approve delete_files?"
    User->>Agent: "Yes"
    Agent->>Tool: Execute
    Tool-->>User: "Deleted 5 files"
```

***

## Configuration Levels

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
// 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

| Option        | Description                    |
| ------------- | ------------------------------ |
| `autoApprove` | Patterns to auto-approve       |
| `autoDeny`    | Patterns to auto-deny          |
| `timeout`     | Time to wait for response (ms) |
| `handler`     | Custom approval function       |

***

## API Reference

<Card title="ApprovalCallbackConfig" icon="code" href="/docs/sdk/reference/typescript/classes/ApprovalCallbackConfig">
  Complete configuration options
</Card>

***

## Best Practices

<AccordionGroup>
  <Accordion title="Auto-approve safe actions">
    Reading data is usually safe to auto-approve.
  </Accordion>

  <Accordion title="Auto-deny dangerous patterns">
    Block delete, execute, and similar risky operations.
  </Accordion>

  <Accordion title="Set reasonable timeouts">
    Default to 60 seconds; adjust based on your workflow.
  </Accordion>
</AccordionGroup>

***

## Related

<CardGroup cols={2}>
  <Card title="Guardrails" icon="shield" href="/docs/js/guardrails">
    Input/output validation
  </Card>

  <Card title="Security" icon="lock" href="/docs/js/security">
    Security features
  </Card>
</CardGroup>
