{"record":{"id":"3fad4058661a66c7","repo":"vercel/ai","slug":"acp-authentication-method-json-stringify-methodi","errorCode":null,"errorMessage":"ACP authentication method ${JSON.stringify(methodId)} is not advertised by the agent. Advertised methods: ${advertised}.","messagePattern":"ACP authentication method (.+?) is not advertised by the agent\\. Advertised methods: (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/harness-acp/src/v1/bridge/protocol-configuration.ts","lineNumber":106,"sourceCode":"}): void {\n  if (initialization.protocolVersion !== requested) {\n    throw new Error(\n      `ACP protocol negotiation failed: requested v${requested}, agent selected v${initialization.protocolVersion}.`,\n    );\n  }\n}\n\nexport function assertACPAuthenticationMethod({\n  initialization,\n  methodId,\n}: {\n  initialization: ACPInitializeResult;\n  methodId: string;\n}): void {\n  if (!initialization.authMethods?.some(method => method.id === methodId)) {\n    const advertised =\n      initialization.authMethods?.map(method => method.id).join(', ') || 'none';\n    throw new Error(\n      `ACP authentication method ${JSON.stringify(methodId)} is not advertised by the agent. Advertised methods: ${advertised}.`,\n    );\n  }\n}\n\nfunction mergeRecords({\n  left,\n  right,\n}: {\n  left: Readonly<Record<string, unknown>>;\n  right: Readonly<Record<string, unknown>>;\n}): Readonly<Record<string, unknown>> {\n  const result: Record<string, unknown> = { ...left };\n  for (const [key, value] of Object.entries(right)) {\n    const previous = result[key];\n    result[key] =\n      isRecord(previous) && isRecord(value)\n        ? mergeRecords({ left: previous, right: value })","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness-acp/src/v1/bridge/protocol-configuration.ts#L88-L124","documentation":"assertACPAuthenticationMethod validates, after ACP initialization, that the auth method id passed to authenticate() was actually advertised by the agent in its initialize response (initialization.authMethods). The library throws this to prevent authenticating with a method the agent cannot perform. The error message includes the requested method id and the full list of advertised method ids for debugging.","triggerScenarios":"Calling authenticate (via the ACP bridge) with a methodId that is not present in initialization.authMethods, e.g. a hardcoded id like 'oauth' when the agent only advertises other ids; also occurs when authMethods is missing/empty, in which case the advertised list shows 'none'.","commonSituations":"Configuring a harness with an auth method copied from a different agent version; an agent upgraded/downgraded so its advertised auth methods changed; a typo in the method id; agent fails to advertise any auth methods.","solutions":["Log or inspect initialization.authMethods after connecting and pick one of the advertised ids for authenticate().","Update the harness/bridge configuration to use the method id the current agent version advertises.","Fix typos or stale ids in the auth configuration (method ids are exact string matches).","If the agent advertises no methods ('none'), fix the agent side or use an auth path that does not require ACP authenticate."],"exampleFix":"// before\nawait bridge.authenticate({ methodId: 'oauth2' });\n// after\nconst { initialization } = await bridge.initialize();\nconst methodId = initialization.authMethods?.[0]?.id;\nif (methodId) await bridge.authenticate({ methodId });","handlingStrategy":"validation","validationCode":"const methods = initialization.authMethods?.map(m => m.id) ?? [];\nif (!methods.includes(methodId)) {\n  throw new Error(`Auth method ${methodId} not advertised; available: ${methods.join(', ') || 'none'}`);\n}","typeGuard":"function isAdvertisedAuthMethod(initialization: ACPInitializeResult, methodId: string): boolean {\n  return initialization.authMethods?.some(m => m.id === methodId) ?? false;\n}","tryCatchPattern":"try {\n  await bridge.authenticate({ methodId });\n} catch (error) {\n  if (error instanceof Error && error.message.includes('is not advertised')) {\n    const advertised = error.message.match(/Advertised methods: (.*)\\.$/)?.[1];\n    console.error(`Pick one of: ${advertised}`);\n  }\n  throw error;\n}","preventionTips":["Always derive the auth method id from initialization.authMethods rather than hardcoding it.","Pin agent versions so advertised capabilities do not drift.","Log advertised auth methods at startup for easier debugging."],"tags":["acp","authentication","configuration"],"backgroundTag":"unsupported-auth-method","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}