Quick start
Approval Types
| Type | Behavior | Use Case |
|---|---|---|
@approval(type="required") or @approval“ | Blocking: Run pauses until an admin reviews and resolves the database record. | Critical actions such as deletion, payments, bulk emails. |
@approval(type="audit") | Non-blocking: Run continues immediately after the HITL interaction is resolved and an audit log is created. | Compliance and activity auditing purposes. |
Blocking
By default,@approval needs HITL approval and requires_confirmation=True is set.
Non-blocking
To enable an audit-style (non-blocking) Human-in-the-Loop flow for persistent audit trails, use@approval(type="audit"). This will create an audit log after the HITL interaction is resolved.
You can use the @tool decorator with log_approval=True to explicitly signal that this tool’s execution should be logged in the HITL audit system.
See User Confirmation for details.
Execution Flow
There are three distinct phases in the approval flow:- The Pause: When a user triggers an @approval tool, the SDK automatically pauses the run and inserts a pending record into your database.
-
Admin Approval: Admin views the list of pending requests. Then update the record status via the DB provider. Use
expected_status="pending"to prevent race conditions. -
Resuming the Run: Continue the run using the
run_id. The SDK verifies the resolution before proceeding. If the record is missing or still pending, continue_run raises a RuntimeError.
Examples
Blocking approvals
@approval + requires_confirmation: pause, DB record, resolve, continue.
Approval list and resolve
Full lifecycle: pause, list pending, resolve via DB, continue.
Approval with user input
@approval + requires_user_input.
Approval with external execution
@approval + external_execution.
Team approval
Team-level approval when a member agent uses an @approval tool.
Audit approval
@approval(type=“audit”) + requires_confirmation; no pause, audit record only.
Developer Resources
- Example code: Approvals cookbook.
- Approval reference
- Tool decorator