Approval flow
requiresApproval on tool()
AddrequiresApproval: true to any tool definition. The framework will throw ApprovalRequiredError before calling execute, giving your application a chance to intercept the call and ask for human approval.
DeferredToolRequests
WhenApprovalRequiredError is thrown, err.deferred is a DeferredToolRequests object. Its requests array contains one entry for each tool the model called simultaneously. Each entry is a DeferredToolRequest:
deferred.requests to build your approval UI and construct the results array:
ExternalToolset
UseExternalToolset when tool execution happens client-side and you have a raw JSON Schema instead of a Zod schema. ExternalToolset automatically sets requiresApproval: true on every tool - the intent is always to throw ApprovalRequiredError, let the client execute the tool, then resume with the result.
ExternalToolset vs requiresApproval: true on tool()Use
requiresApproval: true on tool() when you have a Zod schema and a server-side execute function, but want human approval before it runs.Use ExternalToolset when tool execution happens client-side/externally and you have a raw JSON Schema instead of Zod. ExternalToolset sets requiresApproval: true automatically.Approving with modified args
To re-run a tool with different arguments (for example, letting a human correct a filename before proceeding), provideargsOverride instead of result in the resume results:
argsOverride is present, the framework re-invokes the tool’s execute function with the new arguments. When result is present, the framework injects it directly as the tool result without calling execute.
API reference
Tools
Define tools with Zod schemas and execute functions
Toolsets
Group tools into reusable toolsets including ExternalToolset