Skip to main content
Passing handlers makes the run interactive — the app forwards the agent’s ask_user and confirm_action to your callbacks (over MCP elicitation) while .text() runs. There’s no event loop to drive; the handlers are called as needed, and they may block on a human for up to ~2 minutes.
The two handlers are independent: with only on_confirm, the run is question-free (the agent is never offered ask_user) but every approval gate reaches your handler; with only on_question, questions reach you while confirmations auto-resolve (approve safe, decline dangerous).

Guide: attended vs unattended

The full handler matrix, timeouts, and the safe-by-default rule.