- Sensitive operations
- API calls that modify data
- Actions with significant consequences
How It Works
When you mark a tool withrequires_confirmation=True, your agent will:
- Pause execution when the tool is about to be called
- Set
is_pausedtoTrueon the run response - Wait for you to review the tool call and decide whether to approve or reject it
- Continue execution once you call
continue_run()with your decision
Basic Example
The following example shows how to implement user confirmation with a custom tool:Toolkit-Level Confirmation
You can also specify which specific tools in a toolkit require confirmation using therequires_confirmation_tools parameter. This is super useful when you want to protect only certain operations in a toolkit while allowing others to run freely:
Providing Rejection Feedback
When rejecting a tool call, you can provide feedback to the agent using theconfirmation_note property. This helps the agent understand why the operation was rejected and potentially choose a better approach:
Mixed Tool Scenarios
You can mix tools that require confirmation with tools that don’t. The agent will execute the non-confirmation tools automatically and only pause for those that need approval:Async Support
User confirmation works seamlessly with async agents. Just usearun() and acontinue_run():
Streaming Support
User confirmation also works with streaming responses. The agent will pause mid-stream when it encounters a tool that requires confirmation:Usage Examples
Basic Confirmation
Simple user confirmation flow
Async Confirmation
Using confirmation with async agents
Mixed Tools
Combining confirmation and non-confirmation tools
Multiple Tools
Handling multiple confirmations
Streaming Async
Confirmation with streaming responses
Toolkit Confirmation
Using confirmation with toolkits
With History
Confirmation with chat history
With Run ID
Resume confirmation using run_id
Developer Resources
- View Cookbook