{"record":{"id":"82e02970ed0294f8","repo":"vercel/ai","slug":"ai-unsupportedfunctionalityerror-82e029","errorCode":"AI_UnsupportedFunctionalityError","errorMessage":"'tool choice type: ${_exhaustiveCheck}' functionality not supported.","messagePattern":"'tool choice type: (.+?)' functionality not supported\\.","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/alibaba/src/alibaba-prepare-tools.ts","lineNumber":74,"sourceCode":"  const type = toolChoice.type;\n\n  switch (type) {\n    case 'auto':\n    case 'none':\n    case 'required':\n      return { tools: alibabaTools, toolChoice: type, toolWarnings };\n    case 'tool':\n      return {\n        tools: alibabaTools,\n        toolChoice: {\n          type: 'function',\n          function: { name: toolChoice.toolName },\n        },\n        toolWarnings,\n      };\n    default: {\n      const _exhaustiveCheck: never = type;\n      throw new UnsupportedFunctionalityError({\n        functionality: `tool choice type: ${_exhaustiveCheck}`,\n      });\n    }\n  }\n}\n","sourceCodeStart":56,"sourceCodeEnd":80,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/alibaba/src/alibaba-prepare-tools.ts#L56-L80","documentation":"prepareTools maps AI SDK toolChoice values ('auto','none','required','tool') to Alibaba's API. When the internal discriminated union's type falls through all known cases, an exhaustive-check default branch throws UnsupportedFunctionalityError. Hitting it means an unknown/unmapped tool choice type reached the provider.","triggerScenarios":"Calling generateText/streamText with a toolChoice whose type is not one of the Alibaba provider's mapped variants — typically a newer AI SDK toolChoice type used with an outdated @ai-sdk/alibaba version.","commonSituations":"Version mismatch: users upgrade the core 'ai' package (which adds new toolChoice kinds) but keep an older alibaba provider package that does not handle the new type.","solutions":["Update @ai-sdk/alibaba to the latest version so new toolChoice types are mapped","In the meantime use toolChoice: 'auto' | 'none' | 'required' or { type: 'tool', toolName } which are supported","Pin 'ai' and '@ai-sdk/alibaba' to compatible versions"],"exampleFix":"// before\ntoolChoice: { type: 'someNewKind' } as any\n// after\ntoolChoice: { type: 'tool', toolName: 'getWeather' }","handlingStrategy":"try-catch","validationCode":"const supported = ['auto','none','required','tool'];\nif (toolChoice && !supported.includes(toolChoice.type)) throw new Error(`toolChoice type ${toolChoice.type} unsupported by @ai-sdk/alibaba`);","typeGuard":"function isSupportedToolChoice(tc: unknown): boolean {\n  const t = (tc as { type?: string } | undefined)?.type;\n  return t === undefined || ['auto','none','required','tool'].includes(t);\n}","tryCatchPattern":"try {\n  await generateText({ ...args, toolChoice });\n} catch (e) {\n  if (UnsupportedFunctionalityError.isInstance(e) && e.functionality.startsWith('tool choice type')) {\n    return generateText({ ...args, toolChoice: 'auto' });\n  }\n  throw e;\n}","preventionTips":["Keep @ai-sdk/alibaba and 'ai' on matching versions","Only use documented toolChoice values with Alibaba models","Test tool-choice paths after any SDK upgrade"],"tags":["tool-choice","unsupported-functionality","version-mismatch"],"backgroundTag":"unsupported-tool-choice","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}