vercel/ai · error · CodeModeToolApprovalRequiredError
CODE_MODE_TOOL_APPROVAL_REQUIRED
CODE_MODE_TOOL_APPROVAL_REQUIRED
Error message
Tool "${toolName}" requires approval before execution. What it means
Error "Tool "${toolName}" requires approval before execution." thrown in vercel/ai.
Source
Thrown at packages/code-mode/src/tool-invocation.ts:119
toolName,
input: validation.value,
toolCallId,
payload: { kind: CODE_MODE_TOOL_APPROVAL_KIND },
};
}
const approval = await raceAgainstAbort(
Promise.resolve(
codeModeOptions.approval?.onApprovalRequired?.({
toolName,
input: validation.value,
toolCallId,
}),
),
baseExecutionOptions.abortSignal,
);
if (approval === undefined) {
throw new CodeModeToolApprovalRequiredError(
toolName,
validation.value,
toolCallId,
);
}
const approved =
typeof approval === 'string'
? approval === 'approved'
: approval?.approved;
const reason = typeof approval === 'string' ? undefined : approval?.reason;
if (typeof approved !== 'boolean') {
throw new CodeModeProtocolError(
`Tool "${toolName}" approval callback returned a malformed approval decision.`,
{ toolName, toolCallId },
);
}
if (reason !== undefined && typeof reason !== 'string') {
throw new CodeModeProtocolError(View on GitHub (pinned to 69428b1f8b)
When it happens
Trigger: Thrown at packages/code-mode/src/tool-invocation.ts:119 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/486a34ec5c07c7a4.
Report an issue: GitHub.