# Practical and Useful Patterns with ADK
✋ "Are you sure you want to send this email?" — ADK's Action Confirmations add pre-execution user approval for irreversible operations, building safer agents.
📌 Title: Action Confirmations — Pre-Execution Approval for Irreversible Operations
🔗 URL:
🧩 Overview
ADK's Action Confirmations require explicit user approval before executing hard-to-reverse operations like email sending, data deletion, and payment processing. The agent asks "Should I proceed?" and only executes upon user approval. This maintains human control at critical decision points while keeping agents autonomous for routine tasks.
🛠 Usage
Defining tools with confirmation requirements.
To define tools with confirmation, import `Agent` and `ToolContext` from `google.adk`. In `send_email(to: str, subject: str, body: str, tool_context: ToolContext)`, call `tool_context.actions.request_confirmation(message=...)` before the actual send, displaying a preview with recipient, subject, and body. The email is only sent if the user approves. Similarly, `delete_records(table: str, condition: str, tool_context: ToolContext)` counts records to be deleted first, then displays the count in a confirmation message for user approval. Pass both tools to an `Agent` with `name="admin_assistant"` and `model="gemini-2.5-flash"` via the `tools` parameter.
🏗 Practical Patterns
**When to Require Confirmation**: Add confirmation for these categories:
- External sends (email, messages, API calls)
- Data modification or deletion
- Operations that incur charges
- Permission or access control changes
For payment processing, define `process_payment(amount: float, currency: str, recipient: str, tool_context: ToolContext)`. This function calls `tool_context.actions.request_confirmation(message=...)` with the recipient, currency, and amount details. Only after user approval does it execute `payment_gateway.charge(amount=..., currency=..., recipient=...)` to process the transaction.
**Confirmation Message Design**: Include the target, scope of impact, and irreversibility in confirmation messages. Provide exactly the information users need to make an informed decision.
**Staged Confirmations**: For multi-step operations, decide whether to confirm at each step or summarize at the final step. Balance thoroughness with user experience.
💡 Use Cases
📧 Email and message send confirmation
🗑️ Database record deletion approval
💳 Payment and transfer execution confirmation
🔐 Permission and access control change approval
⚠️ Caveats
- Too many confirmations degrade user experience. Limit confirmations to truly irreversible operations.
- Insufficient confirmation messages prevent users from making informed decisions. Be specific about the operation's impact.
- Confirmations become bottlenecks in batch processing and automation pipelines. Consider skippable confirmations for automated scenarios.
✨ Properly configured Action Confirmations balance agent autonomy with human safety oversight. The key is confirming only "can't-undo" operations!
#
ADK# #
AIAgent#