fix(openai): handle file-url parts in Responses tool result content#13713
Open
s-zx wants to merge 1 commit intovercel:mainfrom
Open
fix(openai): handle file-url parts in Responses tool result content#13713s-zx wants to merge 1 commit intovercel:mainfrom
s-zx wants to merge 1 commit intovercel:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The OpenAI Responses provider converts tool result
contentparts into API input items insideconvertToOpenAIResponsesInput. Three content part types were already handled:textinput_textimage-datainput_image(base64)image-urlinput_image(url)file-datainput_file(base64)However
file-urlparts fell through to thedefaultbranch, which emits a warning and returnsundefined— causing the part to be silently dropped.Root cause
In
packages/openai/src/responses/convert-to-openai-responses-input.ts, both thefunction_call_outputcontent mapping and thecustom_tool_call_outputcontent mapping were missing afile-urlcase.Fix
Add a
file-urlcase in both switch blocks that maps to{ type: 'input_file', file_url: item.url }, consistent with how the OpenAI Responses API represents file URLs:This mirrors the existing
file-datapath and matches theinput_fileshape already used for PDF URL parts in theusermessage handler.Fixes #13622