{"record":{"id":"ee8674c2ebdfedb0","repo":"vercel/ai","slug":"acp-permission-mapping-for-json-stringify-permis","errorCode":null,"errorMessage":"ACP permission mapping for ${JSON.stringify(permissionMode)} requires session mode ${JSON.stringify(target.modeId)}, but the agent advertised ${formatChoices({ values: availableModeIds })}.","messagePattern":"ACP permission mapping for (.+?) requires session mode (.+?), but the agent advertised (.+?)\\)\\}\\.","errorType":"exception","errorClass":"HarnessBridgeCapabilityUnsupportedError","httpStatus":null,"severity":"error","filePath":"packages/harness-acp/src/v1/bridge/permission-mode.ts","lineNumber":89,"sourceCode":"  });\n}\n\nfunction validateTarget({\n  target,\n  permissionMode,\n  sessionConfiguration,\n  harnessId,\n}: {\n  target: ACPPermissionModeTarget;\n  permissionMode: HarnessV1PermissionMode;\n  sessionConfiguration: ACPSessionConfiguration;\n  harnessId: string;\n}): void {\n  if (target.type === 'session-mode') {\n    const availableModeIds =\n      sessionConfiguration.modes?.availableModes.map(mode => mode.id) ?? [];\n    if (!availableModeIds.includes(target.modeId)) {\n      throw unsupported({\n        harnessId,\n        message:\n          `ACP permission mapping for ${JSON.stringify(permissionMode)} requires session mode ` +\n          `${JSON.stringify(target.modeId)}, but the agent advertised ` +\n          `${formatChoices({ values: availableModeIds })}.`,\n      });\n    }\n    return;\n  }\n\n  const configOption = sessionConfiguration.configOptions?.find(\n    option => option.id === target.configId,\n  );\n  if (configOption == null) {\n    const availableConfigIds =\n      sessionConfiguration.configOptions?.map(option => option.id) ?? [];\n    throw unsupported({\n      harnessId,","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness-acp/src/v1/bridge/permission-mode.ts#L71-L107","documentation":"When the permission mode maps to an ACP 'session-mode' target, validateTarget checks that the modeId the harness wants to switch to was advertised by the agent in the session's modes.availableModes. If the agent did not advertise that mode id, the harness throws this unsupported error listing the modes the agent actually offers.","triggerScenarios":"configureACPPermissionMode resolves the permissionMode to a { type: 'session-mode', modeId } mapping whose modeId is not present in sessionConfiguration.modes.availableModes (or the agent advertised no modes at all).","commonSituations":"Hard-coded mapping for an agent version whose mode ids changed (e.g. 'acceptEdits' vs 'accept-edits'); connecting to an agent that simply doesn't offer the required mode; stale harness config after an agent upgrade.","solutions":["Pick a permissionMode whose mapped modeId appears in the agent's advertised availableModes (the error lists them).","Update the harness's permissionModeMapping to use one of the advertised mode ids.","Upgrade or fix the agent so it advertises the expected session mode."],"exampleFix":"// before (mapping points at an unadvertised mode)\npermissionModeMapping: { default: { type: 'session-mode', modeId: 'acceptEdits' } }\n// after (use an id the agent advertised)\npermissionModeMapping: { default: { type: 'session-mode', modeId: 'accept-edits' } }","handlingStrategy":"validation","validationCode":"const advertised = (sessionConfiguration.modes?.availableModes ?? []).map(m => m.id);\nif (!advertised.includes(target.modeId)) {\n  throw new Error(`modeId ${target.modeId} not advertised; pick one of ${advertised.join(', ')}`);\n}","typeGuard":"const isAdvertisedMode = (modeId: string, cfg: SessionConfiguration): boolean =>\n  (cfg.modes?.availableModes ?? []).some(m => m.id === modeId);","tryCatchPattern":null,"preventionTips":["Discover availableModes at session start and derive mappings from them instead of hard-coding.","Re-validate mappings whenever the agent version changes.","Avoid hand-typing mode ids; copy them from the advertised payload."],"tags":["acp","permissions","session-mode","configuration-mismatch"],"backgroundTag":"unsupported-permission-mode","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}