{"record":{"id":"d870dfe39c0c21f3","repo":"vercel/ai","slug":"code-mode-protocol-error-d870df","errorCode":"CODE_MODE_PROTOCOL_ERROR","errorMessage":"Tool \"${toolName}\" approval callback returned a malformed approval decision.","messagePattern":"Tool \"(.+?)\" approval callback returned a malformed approval decision\\.","errorType":"exception","errorClass":"CodeModeProtocolError","httpStatus":null,"severity":"error","filePath":"packages/code-mode/src/tool-invocation.ts","lineNumber":131,"sourceCode":"          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(\n        `Tool \"${toolName}\" approval callback returned a malformed approval reason.`,\n        { toolName, toolCallId },\n      );\n    }\n    if (!approved) {\n      throw new CodeModeToolApprovalDeniedError(\n        toolName,\n        validation.value,\n        toolCallId,\n        reason,\n      );\n    }","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/code-mode/src/tool-invocation.ts#L113-L149","documentation":"Error \"Tool \"${toolName}\" approval callback returned a malformed approval decision.\" thrown in vercel/ai.","triggerScenarios":"Thrown at packages/code-mode/src/tool-invocation.ts:131 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"}