vercel/ai · error · CodeModeProtocolError

CODE_MODE_PROTOCOL_ERROR

CODE_MODE_PROTOCOL_ERROR

Error message

Approval response ${approvalResponse.approvalId} does not match pending code-mode approval ${interrupt.interruptId}.

What it means

Error "Approval response ${approvalResponse.approvalId} does not match pending code-mode approval ${interrupt.interruptId}." thrown in vercel/ai.

Source

Thrown at packages/code-mode/src/approval-continuation.ts:45

  );
}

export async function continueCodeModeApproval({
  interrupt,
  approvalResponse,
  tools,
  options = {},
  toolExecutionOptions,
}: {
  interrupt: CodeModeApprovalInterrupt;
  approvalResponse: CodeModeApprovalResponse;
  tools: CodeModeToolSet;
  options?: CodeModeOptions;
  toolExecutionOptions?: Partial<CodeModeToolExecutionOptions>;
}): Promise<unknown> {
  assertCodeModeApprovalResponse(approvalResponse);
  if (approvalResponse.approvalId !== interrupt.interruptId) {
    throw new CodeModeProtocolError(
      `Approval response ${approvalResponse.approvalId} does not match pending code-mode approval ${interrupt.interruptId}.`,
    );
  }

  return await continueCodeModeInterrupt({
    interrupt,
    resolution: {
      approved: approvalResponse.approved,
      ...(approvalResponse.reason !== undefined
        ? { reason: approvalResponse.reason }
        : {}),
    },
    tools,
    options: {
      ...options,
      approval: { ...options.approval, mode: 'interrupt' },
    },
    ...(toolExecutionOptions !== undefined ? { toolExecutionOptions } : {}),

View on GitHub (pinned to 69428b1f8b)

When it happens

Trigger: Thrown at packages/code-mode/src/approval-continuation.ts:45 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/0bc2bf3655709f5a. Report an issue: GitHub.