Skip to main content
Many agent frameworks support the ability to request user approval before executing certain actions. This is especially useful when an agent is calling external tools that may have significant effects or costs associated with their usage. The Approval Extension pauses execution and prompts the user with the tool details, resuming only after approval is granted.

Basic Implementation

To implement approvals, you inject the extension and call request_approval() within your tool execution logic or a framework handler. This example uses the BeeAI Framework to request user approval before executing a tool call:
1

Import the Approval extension

Import ApprovalExtensionServer, ApprovalExtensionSpec, ApprovalExtensionParams, and ToolCallApprovalRequest from agentstack_sdk.a2a.extensions.
2

Inject the extension

Add an approval parameter to your agent function using the Annotated type hint with ApprovalExtensionServer and ApprovalExtensionSpec.
3

Request user approval

Within your agent logic or tool handler, call await approval_ext.request_approval(). This triggers a UI prompt for the user and pauses execution until they respond.
4

Handle the response

Access the approved boolean from the response. If True, proceed with the tool execution; if False, handle the rejection gracefully (e.g., by yielding a message to the user).