Skip to main content

Approval Module

The Approval module provides a minimal human-in-the-loop approval system for dangerous tool operations. It extends the existing callback system to require human approval before executing high-risk tools.

Import

Quick Example

Risk Levels

Decorators

@require_approval(risk_level)

Marks a tool as requiring human approval before execution. Parameters:
  • risk_level (str): One of “critical”, “high”, “medium”, “low”

Functions

set_approval_callback(callback_fn)

Set a custom approval callback function. Parameters:
  • callback_fn: Function that accepts (function_name, arguments, risk_level) and returns ApprovalDecision

get_approval_callback()

Get the current approval callback function. Returns: The current callback or None

mark_approved(tool_name)

Mark a tool as approved in the current context.

is_already_approved(tool_name)

Check if a tool is already approved in the current context. Returns: bool

clear_approval_context()

Clear the approval context (reset all approvals).

ApprovalDecision Class

Example: Custom Approval UI

Example: Automatic Approval for Low Risk

Global Registries