Skip to content

fix(openai): handle file-url parts in Responses tool result content#13713

Open
s-zx wants to merge 1 commit intovercel:mainfrom
s-zx:fix/13622-responses-file-url-tool-result
Open

fix(openai): handle file-url parts in Responses tool result content#13713
s-zx wants to merge 1 commit intovercel:mainfrom
s-zx:fix/13622-responses-file-url-tool-result

Conversation

@s-zx
Copy link

@s-zx s-zx commented Mar 21, 2026

Summary

The OpenAI Responses provider converts tool result content parts into API input items inside convertToOpenAIResponsesInput. Three content part types were already handled:

Part type Mapped to
text input_text
image-data input_image (base64)
image-url input_image (url)
file-data input_file (base64)

However file-url parts fell through to the default branch, which emits a warning and returns undefined — causing the part to be silently dropped.

Root cause

In packages/openai/src/responses/convert-to-openai-responses-input.ts, both the function_call_output content mapping and the custom_tool_call_output content mapping were missing a file-url case.

Fix

Add a file-url case in both switch blocks that maps to { type: 'input_file', file_url: item.url }, consistent with how the OpenAI Responses API represents file URLs:

case 'file-url': {
  return {
    type: 'input_file' as const,
    file_url: item.url,
  };
}

This mirrors the existing file-data path and matches the input_file shape already used for PDF URL parts in the user message handler.

Fixes #13622

The OpenAI Responses provider converts tool result content parts into
API input items. image-url and file-data parts were already supported,
but file-url parts fell through to the default warning branch and were
silently dropped.

Map file-url content parts to { type: 'input_file', file_url: url }
in both the regular function_call_output path and the
custom_tool_call_output path so that tools whose toModelOutput
returns file-url parts work correctly.

Fixes vercel#13622
@tigent tigent bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/openai Issues related to the @ai-sdk/openai provider labels Mar 21, 2026
Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

The OpenAIResponsesFunctionCallOutput type's output array union is missing the { type: 'input_file'; file_url: string } variant, causing a type mismatch with code that produces this variant.

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/openai Issues related to the @ai-sdk/openai provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI Responses provider ignores file-url parts in tool response

2 participants