approval answers approve (by the user) for matching calls until the person confirms that exact call. By default it matches high tier tools. It is about the person the agent works for pressing an approve button; approval by someone else (a reviewer) comes from the policy through permissions.
guards.approval({ when: { tier: ["medium", "high"] }, message: (text) => `${text}. Reply yes to go ahead.` });Options#
whenobject or function
Which calls need confirmation: tier, tools or a function of the call. Default: tier: "high".
messagefunction
Rewrites the confirmation text. It receives the default text, Confirm: followed by a short description of the call, for example Confirm: refund_invoice (invoice_id INV-1, amount 90). The description lists up to four string, number or boolean arguments, each cut to 60 characters.
modeenforce, monitor or observe
Overrides the harness mode.
When a call passes#
A matching call passes the guard when either is true:
- The framework says the person approved it. With the Vercel AI SDK, a tool approval response for the call's approval request counts. With your own loop, pass approvedByUser: true (Python and Ruby: approved_by_user) to run.check().
- You recorded a confirmation. Call run.confirm(tool, args) when the person confirms in your UI. The next call with the same tool and the same arguments passes once. Argument order does not matter; any other value does.
A confirmation is single-use and only used in enforce mode. In Python and Ruby it is used up only when the call runs; in TypeScript it is used up when this guard passes the call, even if a later guard stops it.
const verdict = await run.check("refund_invoice", args);if (verdict.kind === "approve" && verdict.decision.approve?.by === "user") { // show verdict.decision.message with an approve button; when pressed: await run.confirm("refund_invoice", args);}Decision#
{ "kind": "approve", "reason": "confirmation_required", "message": "Confirm: refund_invoice (invoice_id INV-1, amount 90)", "approve": { "by": "user" } }The model reads Confirm: refund_invoice (invoice_id INV-1, amount 90) Ask them to confirm, then try again.