{"record":{"id":"486a34ec5c07c7a4","repo":"vercel/ai","slug":"code-mode-tool-approval-required","errorCode":"CODE_MODE_TOOL_APPROVAL_REQUIRED","errorMessage":"Tool \"${toolName}\" requires approval before execution.","messagePattern":"Tool \"(.+?)\" requires approval before execution\\.","errorType":"exception","errorClass":"CodeModeToolApprovalRequiredError","httpStatus":null,"severity":"error","filePath":"packages/code-mode/src/tool-invocation.ts","lineNumber":119,"sourceCode":"        toolName,\n        input: validation.value,\n        toolCallId,\n        payload: { kind: CODE_MODE_TOOL_APPROVAL_KIND },\n      };\n    }\n\n    const approval = await raceAgainstAbort(\n      Promise.resolve(\n        codeModeOptions.approval?.onApprovalRequired?.({\n          toolName,\n          input: validation.value,\n          toolCallId,\n        }),\n      ),\n      baseExecutionOptions.abortSignal,\n    );\n    if (approval === undefined) {\n      throw new CodeModeToolApprovalRequiredError(\n        toolName,\n        validation.value,\n        toolCallId,\n      );\n    }\n    const approved =\n      typeof approval === 'string'\n        ? approval === 'approved'\n        : approval?.approved;\n    const reason = typeof approval === 'string' ? undefined : approval?.reason;\n    if (typeof approved !== 'boolean') {\n      throw new CodeModeProtocolError(\n        `Tool \"${toolName}\" approval callback returned a malformed approval decision.`,\n        { toolName, toolCallId },\n      );\n    }\n    if (reason !== undefined && typeof reason !== 'string') {\n      throw new CodeModeProtocolError(","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/code-mode/src/tool-invocation.ts#L101-L137","documentation":"Error \"Tool \"${toolName}\" requires approval before execution.\" thrown in vercel/ai.","triggerScenarios":"Thrown at packages/code-mode/src/tool-invocation.ts:119 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}