@approval sets requires_confirmation=True automatically if none is set.
Approvals work at both the agent and team level. When a member agent in a team calls an
@approval tool, the team run pauses with the same flow shown below. See the Team approval example.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.
@approval(type="audit") requires at least one HITL flag (requires_confirmation=True, requires_user_input=True, or external_execution=True) on the @tool() decorator.
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_idandsession_id. When called withoutrequirements, the SDK verifies the resolution and applies it before proceeding. If the record is missing or still pending, continue_run raises a ValueError.
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 approvals
Three patterns: tool on the team, on a member agent, or on both.
Audit approval
@approval(type=“audit”) + requires_confirmation: pause, confirm, continue, audit record (no admin gate).
Developer Resources
- Example code: Approvals cookbook.
- Approval reference
- Tool decorator