Basic Implementation
To implement approvals, you inject the extension and callrequest_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).