vercel/ai · error · UnsupportedFunctionalityError
tool result file data of type
Error message
tool result file data of type "${contentPart.data.type}" What it means
In tool-result conversion, a file part is only accepted when it is inline 'data' or an 's3:' protocol URL. Any other type (e.g. a plain https URL, or other data carrier types) triggers UnsupportedFunctionalityError with the offending data type in the message. Bedrock cannot fetch arbitrary web URLs for tool result files.
Solutions
- Return the file as inline 'data' (base64/Uint8Array) from the tool with a supported media type.
- Upload the file to S3 and return a file part with an s3:// URL.
- Convert the file content to text and return it as a text tool result part instead.
- Verify the tool result file part shape matches the AI SDK FilePart data union.
Example fix
// before (in tool result content)
{ type: 'file', mediaType: 'application/pdf', data: new URL('https://cdn.example.com/report.pdf') }
// after
{ type: 'file', mediaType: 'application/pdf', data: await downloadBytes('https://cdn.example.com/report.pdf'), filename: 'report.pdf' } Defensive patterns
Strategy: validation
Validate before calling
function validateToolResultFile(part) {
if (part.type !== 'file') return true;
const ok = part.data.type === 'data' || (part.data.type === 'url' && part.data.url.protocol === 's3:');
if (!ok) throw new Error(`Tool result file must be inline data or s3: URL, got: ${part.data.type}`);
return true;
} Type guard
function isInlineOrS3FileData(data) {
return data.type === 'data' || (data.type === 'url' && data.url.protocol === 's3:');
} Try / catch
try {
return await generateText({ model, prompt });
} catch (error) {
if (UnsupportedFunctionalityError.isInstance(error) && error.message.includes('tool result file data')) {
console.error('Tool returned an unsupported file data type; inline the bytes or use s3://.');
}
throw error;
} Prevention
- Design tools to return file bytes inline or S3 URIs, never web URLs.
- Add a unit test for every tool's output shape against the Bedrock converter.
- Wrap tool execute() to normalize file parts before they reach the provider.
When it happens
Trigger: A tool returns a file part whose contentPart.data.type is neither 'data' nor 'url' with an s3: protocol — most commonly an https URL file inside a tool result.
Common situations: A tool fetches a document from the web and returns its URL as a file part; Bedrock requires the bytes (inline data) or an S3 location instead.
Related errors
- unsupported tool content part type
- AI_UnsupportedFunctionalityError
- file parts with provider references
- File URL data
- Multiple system messages that are separated by…
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/e0540bef48712835.
Report an issue: GitHub.
Appendix: source
Thrown at packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts:400
continue;
}
let toolResultContent;
const output = part.output;
switch (output.type) {
case 'content': {
toolResultContent = await Promise.all(
output.value.map(async contentPart => {
switch (contentPart.type) {
case 'text':
return { text: contentPart.text };
case 'file': {
if (
contentPart.data.type !== 'data' &&
(contentPart.data.type !== 'url' ||
contentPart.data.url.protocol !== 's3:')
) {
throw new UnsupportedFunctionalityError({
functionality: `tool result file data of type "${contentPart.data.type}"`,
});
}
const fullMediaType = resolveFullMediaType({
part: contentPart,
});
switch (getTopLevelMediaType(fullMediaType)) {
case 'image': {
return {
image: {
format:
getAmazonBedrockImageFormat(
fullMediaType,
),
source: getAmazonBedrockMediaSource({
data: contentPart.data,View on GitHub (pinned to 69428b1f8b)