vercel/ai · error · UnsupportedFunctionalityError
AI_UnsupportedFunctionalityError
AI_UnsupportedFunctionalityError
Error message
'tool choice type: ${_exhaustiveCheck}' functionality not supported. What it means
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.
Source
Thrown at packages/amazon-bedrock/src/amazon-bedrock-prepare-tools.ts:214
) {
const type = toolChoice.type;
switch (type) {
case 'auto':
amazonBedrockToolChoice = { auto: {} };
break;
case 'required':
amazonBedrockToolChoice = { any: {} };
break;
case 'none':
amazonBedrockTools.length = 0;
amazonBedrockToolChoice = undefined;
break;
case 'tool':
amazonBedrockToolChoice = { tool: { name: toolChoice.toolName } };
break;
default: {
const _exhaustiveCheck: never = type;
throw new UnsupportedFunctionalityError({
functionality: `tool choice type: ${_exhaustiveCheck}`,
});
}
}
}
const toolConfig: AmazonBedrockToolConfiguration =
amazonBedrockTools.length > 0
? { tools: amazonBedrockTools, toolChoice: amazonBedrockToolChoice }
: {};
return {
toolConfig,
additionalTools,
betas,
toolWarnings,
};
}View on GitHub (pinned to 69428b1f8b)
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
Example fix
// before
await generateText({ model, tools, toolChoice: { type: 'any' } as any });
// after
await generateText({ model, tools, toolChoice: 'required' }); Defensive patterns
Strategy: validation
Validate before calling
const ok = ['auto','none','required'].includes(toolChoice as string) ||
(typeof toolChoice === 'object' && toolChoice?.type === 'tool' && !!toolChoice.toolName);
if (!ok) throw new Error('Unsupported toolChoice for Bedrock'); Type guard
function isSupportedToolChoice(tc: unknown): boolean {
return tc === 'auto' || tc === 'none' || tc === 'required' ||
(typeof tc === 'object' && tc !== null && (tc as any).type === 'tool');
} Try / catch
try {
await generateText({ model, tools, toolChoice });
} catch (e) {
if (UnsupportedFunctionalityError.isInstance(e)) {
// fall back to toolChoice: 'auto'
}
} Prevention
- Keep `ai` and @ai-sdk/amazon-bedrock versions in sync
- Only use documented toolChoice values; avoid `as any` casts
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- AI_UnsupportedFunctionalityError
- Unsupported task type: ${taskType}
- URL-based images are not supported for Amazon Bedrock image
- Multiple system messages that are separated by user/assistan
- file parts with provider references
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/35d8924e74cd0b77.
Report an issue: GitHub.