guardAiSdkTools takes the tool map you pass to generateText or streamText and returns a copy where every execute calls authorize first. It has no runtime dependency on ai: the tool type is structural.
A refused call does not throw. It resolves to a ToolDenial with the decision code, so the model reads the refusal as the tool result and stops. For the throwing variant built on the policy engine, see Vercel AI SDK.
Runnable snippet
tools to generateText({ model, tools, prompt }) as usual.
Options
If
authorize throws, the call is refused with code guard_error. The guard fails closed.
Approval
undefined, the model gets a denial with approvalRequired: true.