Skip to main content
Before registry tools, MCP tools, or sub-agent delegation execute, the SDK can pause and wait for human approval. One agent-level policy governs all three paths. When an approval is required, the run pauses at that tool call and delivers an ApprovalRequest to your handler (or a CUSTOM event on the stream). The run resumes only after req.Respond() or AgentStream.Approve() is called with Approved or Rejected. If rejected, the tool call is skipped and the LLM receives a clear refusal message, then continues generating a response without that tool result. The overall run does not fail on rejection — only on timeout.

Policies

Set with WithToolApprovalPolicy:
When you omit WithToolApprovalPolicy, the default is require-all. If your agent has tools registered, every run will pause for approval unless you set a policy. For automated or trusted agents, use AutoToolApprovalPolicy().
Custom tools may implement ToolApproval — the configured agent policy overrides tool-level hints when set. Implement AgentToolApprovalPolicy for fully custom policy logic.

Run

Set WithApprovalHandler whenever approvals can occur:
For a non-blocking wait, use the same handler and select on agentRun.Done() before Get — see Non-blocking Run.

Approval request types

Error handling

Respond (and stream Approve) succeed once per approval token. A second call returns ErrApprovalAlreadyResolved — already answered or timed out; usually safe to ignore:
On Temporal, approval state is durable across reconnects — calling Respond / Approve again after a crash returns the same sentinel.

Stream

On Stream, approval and delegation requests arrive as AgentEventTypeCustom events — not via WithApprovalHandler. Parse the event, then call Approve on the stream handle:
Run uses req.Respond() in WithApprovalHandler. Stream uses AgentStream.Approve with the token from the CUSTOM event. Do not mix the two paths.

Sub-agent approval

Parent and specialist agents have independent policies:
The main agent’s policy governs whether delegation itself requires approval. The specialist’s policy governs tool calls inside the specialist. Set each independently.

Approval timeout

WithApprovalTimeout (default: agent timeout − 30s) limits how long the user has to respond. If they do not respond in time: Approval timeout must be less than the agent timeout. See Timeouts & Modes.

Reconnecting after approval

On Temporal, if the process crashes while an approval is pending, reconnect the stream and answer if you have not already:
The CUSTOM approval event is delivered once. If you already responded before the crash, Approve returns ErrApprovalAlreadyResolved. If you crashed before responding, the token stays open until you answer.

Example

Tools

approval and authorizer sub-examples

Non-blocking Run

Non-blocking run with approval handler

Tools

ToolAuthorizer for programmatic gates before approval

Sub-agents

Delegation approval flow