reply.
While paused, reply returns a waiting notice message whose finished_reason is None: the reply is parked, not finished, and no remaining tool calls are executed until the outside result arrives.
User Confirmation
When the permission system determines a tool call needs user approval, the agent emits aRequireUserConfirmEvent and pauses.
1
2
Build the confirmation result
For each pending tool call, create a
ConfirmResult indicating whether to allow or deny it. You can also modify the tool call input or accept suggested permission rules:3
Resume the agent
Pass the
UserConfirmResultEvent back to reply or reply_stream:- Confirmed tool calls execute immediately and the agent continues reasoning
- Denied tool calls produce an error result visible to the LLM, which may retry with a different approach
- Accepted rules are persisted to the permission engine, so matching future calls are auto-allowed without prompting again
External Tool Execution
When the agent calls a tool withis_external_tool = True, it emits a RequireExternalExecutionEvent and pauses. The tool’s logic runs outside the agent, typically by a human operator or an external system.
1
2
Execute externally and build results
Run the operation outside the agent and wrap the results as
ToolResultBlock objects:3
Resume the agent
Pass the The results are injected into the agent’s context and reasoning continues from where it left off.
ExternalExecutionResultEvent back to resume:The Built-in AskUser
AskUser is the framework’s own external execution tool, there for the moments an agent needs a decision from the person it is working for. One call carries up to four questions, each with two to four options — see Ask the User for how to register it.
tc.input in the RequireExternalExecutionEvent has the shape a renderer works from:
A renderer is expected to offer an “Other” free-text answer beside the options, because the tool has already promised the user one.
On the way back,
output is written for the model to read, while the same answers go into metadata shaped by AskUserMetadata, so a program can branch on the choice:
Returning an AskUser answer
If multiple tool calls require outside interaction and only partial confirmation or execution results are passed back, the agent won’t re-send the requiring events for the unconfirmed or unexecuted tool calls.