Skip to main content
The agent pauses execution and emits special events when it encounters two situations: a tool call that requires user confirmation (permission system returns ASK), or a tool marked as external execution (the result must come from outside the agent). In both cases, you resume the agent by passing a result event back via 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 a RequireUserConfirmEvent and pauses.
1

Receive the RequireUserConfirmEvent

Use reply_stream to detect the pause. The event has the following structure:
str
required
ID of the current reply, used to resume the agent.
list[ToolCallBlock]
required
Tool calls pending user confirmation. Each ToolCallBlock contains:
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 with is_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

Receive the RequireExternalExecutionEvent

The event has the following structure:
str
required
ID of the current reply, used to resume the agent.
list[ToolCallBlock]
required
Tool calls to be executed externally. Each ToolCallBlock contains:
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 ExternalExecutionResultEvent back to resume:
The results are injected into the agent’s context and reasoning continues from where it left off.
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.
Use reply_stream when building interactive UIs: it lets you detect pause events in real time and prompt the user immediately. Use reply when you have pre-built automation that handles events programmatically.