{"record":{"id":"35d8924e74cd0b77","repo":"vercel/ai","slug":"ai-unsupportedfunctionalityerror-35d892","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/amazon-bedrock/src/amazon-bedrock-prepare-tools.ts","lineNumber":214,"sourceCode":"  ) {\n    const type = toolChoice.type;\n    switch (type) {\n      case 'auto':\n        amazonBedrockToolChoice = { auto: {} };\n        break;\n      case 'required':\n        amazonBedrockToolChoice = { any: {} };\n        break;\n      case 'none':\n        amazonBedrockTools.length = 0;\n        amazonBedrockToolChoice = undefined;\n        break;\n      case 'tool':\n        amazonBedrockToolChoice = { tool: { name: toolChoice.toolName } };\n        break;\n      default: {\n        const _exhaustiveCheck: never = type;\n        throw new UnsupportedFunctionalityError({\n          functionality: `tool choice type: ${_exhaustiveCheck}`,\n        });\n      }\n    }\n  }\n\n  const toolConfig: AmazonBedrockToolConfiguration =\n    amazonBedrockTools.length > 0\n      ? { tools: amazonBedrockTools, toolChoice: amazonBedrockToolChoice }\n      : {};\n\n  return {\n    toolConfig,\n    additionalTools,\n    betas,\n    toolWarnings,\n  };\n}","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/amazon-bedrock/src/amazon-bedrock-prepare-tools.ts#L196-L232","documentation":"prepareTools maps LanguageModelV4 toolChoice types ('auto', 'none', 'required', 'tool') to Bedrock toolConfig.toolChoice. The default branch is an exhaustiveness guard using UnsupportedFunctionalityError; it fires when a tool choice type has no Bedrock equivalent mapping. Usually means a new tool choice type from the core SDK not yet supported by the Bedrock provider, or a bad cast.","triggerScenarios":"Calling generateText/streamText with toolChoice set to a value the bedrock provider can't map — typically via an untyped/`as any` toolChoice object, or a newer core SDK tool-choice type with an older @ai-sdk/amazon-bedrock.","commonSituations":"Version skew between `ai` and `@ai-sdk/amazon-bedrock`; hand-built toolChoice objects with typos like 'any' or 'force'; programmatically generated toolChoice from config files.","solutions":["Update @ai-sdk/amazon-bedrock (and `ai`) to matching latest versions","Use one of the supported toolChoice values: 'auto', 'none', 'required', or { type: 'tool', toolName: '...' }","Remove type assertions that let invalid toolChoice values through","If a new core tool-choice type is unsupported, file an issue on the bedrock provider"],"exampleFix":"// before\nawait generateText({ model, tools, toolChoice: { type: 'any' } as any });\n// after\nawait generateText({ model, tools, toolChoice: 'required' });","handlingStrategy":"validation","validationCode":"const ok = ['auto','none','required'].includes(toolChoice as string) ||\n  (typeof toolChoice === 'object' && toolChoice?.type === 'tool' && !!toolChoice.toolName);\nif (!ok) throw new Error('Unsupported toolChoice for Bedrock');","typeGuard":"function isSupportedToolChoice(tc: unknown): boolean {\n  return tc === 'auto' || tc === 'none' || tc === 'required' ||\n    (typeof tc === 'object' && tc !== null && (tc as any).type === 'tool');\n}","tryCatchPattern":"try {\n  await generateText({ model, tools, toolChoice });\n} catch (e) {\n  if (UnsupportedFunctionalityError.isInstance(e)) {\n    // fall back to toolChoice: 'auto'\n  }\n}","preventionTips":["Keep `ai` and @ai-sdk/amazon-bedrock versions in sync","Only use documented toolChoice values; avoid `as any` casts"],"tags":["bedrock","tool-choice","unsupported-functionality","exhaustive-switch"],"backgroundTag":"unsupported-functionality","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}