fix: default undefined tool-call input to empty object in convertToModelMessages#14361
Open
Yanhu007 wants to merge 1 commit intovercel:mainfrom
Open
fix: default undefined tool-call input to empty object in convertToModelMessages#14361Yanhu007 wants to merge 1 commit intovercel:mainfrom
Yanhu007 wants to merge 1 commit intovercel:mainfrom
Conversation
…delMessages
When a tool UI part has state 'output-available' but no input field
(e.g. a tool that takes no parameters, or input was not persisted),
convertToModelMessages produces a tool-call without input. The OpenAI
provider sends this without arguments, causing:
Missing required parameter: 'input[N].arguments'
Default undefined input to {} so the provider always has a valid
arguments object to serialize.
Fixes vercel#14349
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
Fixes #14349
When a tool UI part has
state: 'output-available'but noinputfield (e.g. a tool with no parameters, or input not persisted to DB),convertToModelMessagesproduces atool-callpart withinput: undefined. The OpenAI provider then serializes this withoutarguments, causing:This breaks chat history replay permanently — once such a message is persisted, the conversation is stuck.
Fix
Default
part.inputto{}when undefined in the non-error path (line 209):The
output-errorpath already had a fallback chain (part.input ?? rawInput ?? undefined); this adds the same safety to the normal path.