Human-in-the-loop approval workflows for sensitive agent actions.
Overview
The Approvals API enables human oversight of AI agent actions. When an agent attempts a sensitive operation, it creates an approval request that humans review via the web console or API before the action executes.
Core workflow
SDK creates request: Agent calls @guarded_action with requires_human_approval=True
Request submitted: SDK posts to /api/v1/approvals
Human reviews: Approver sees request in web console or via API
Decision made: Approve, reject, or request more info
SDK polls: Agent receives decision via polling endpoint
Action executes: If approved, action proceeds; if rejected, raises error
Intervention is created with type APPROVAL_REQUIRED, outcome BLOCKED
Real-time updates
Approvals support WebSocket real-time updates:
// Web console subscribes to approval eventsws.send(JSON.stringify({ type: 'subscribe', channel: 'approvals'}));// Receive updatesws.onmessage = (event) => { const data = JSON.parse(event.data); if (data.event_type === 'approval_created') { // Show new approval notification } if (data.event_type === 'approval_expired') { // Mark approval as expired }};
Web console workflow
Approvers use the web console to:
Navigate to Approvals page
See pending approvals with expiration countdown
Click “Review” to see full details:
Action description and context
Risk and priority levels
Estimated cost
Input parameters
Agent information
Take action:
Approve with optional notes
Reject with reason
Request Info to ask agent for more context
View decision history in “Decision History” tab
Best practices
Set appropriate timeouts: Critical actions should have short timeouts (5-10 min), routine actions can have longer timeouts (1-24 hours).
Use priority and risk levels: Help approvers triage - critical/high priority items should notify immediately (email, Slack, etc.).
Provide detailed descriptions: Include enough context so approvers can make informed decisions without requesting more info.
Handle expired approvals: SDKs must handle TimeoutError gracefully - don’t assume approvals will be granted within timeout.