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 withWithToolApprovalPolicy:
ToolApproval — the configured agent policy overrides tool-level hints when set.
Implement AgentToolApprovalPolicy for fully custom policy logic.
Run
SetWithApprovalHandler whenever approvals can occur:
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:
Respond / Approve again after a crash returns the same sentinel.
Stream
OnStream, approval and delegation requests arrive as AgentEventTypeCustom events — not via WithApprovalHandler. Parse the event, then call Approve on the stream handle:
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: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
Related
Tools
ToolAuthorizer for programmatic gates before approval
Sub-agents
Delegation approval flow