Skip to content

fix(core): default tool-call input to empty object when undefined in convertToModelMessages#14356

Open
hijingsong wants to merge 1 commit intovercel:mainfrom
hijingsong:clawoss/fix/tool-call-input-default
Open

fix(core): default tool-call input to empty object when undefined in convertToModelMessages#14356
hijingsong wants to merge 1 commit intovercel:mainfrom
hijingsong:clawoss/fix/tool-call-input-default

Conversation

@hijingsong
Copy link
Copy Markdown

Problem

When a tool takes no parameters, the UI message part omits input. convertToModelMessages propagated this as undefined, causing OpenAI to reject the request with:

Missing required parameter: 'arguments'.

Fix

In convertToModelMessages, when building tool-call parts for non-error states, default input to {} when undefined:

- : part.input,
+ : (part.input ?? {}),

This ensures the tool-call always has a valid input value (empty object when no parameters are needed), which serializes to "arguments": "{}" for OpenAI compatibility.

Testing

  • Existing test suite covers tool-call construction with input present (no regressions)
  • The output-error path already handles undefined input via rawInput fallback — this fix applies the same pattern to the non-error path

Fixes #14349

…odelMessages

When a tool has no parameters, the UI message part omits `input`.
convertToModelMessages propagated this omission, causing OpenAI to reject
the request with "Missing required parameter: arguments". Now defaults
to empty object.

Fixes vercel#14349
@tigent tigent bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label ai/ui anything UI related bug Something isn't working as documented provider/openai Issues related to the @ai-sdk/openai provider labels Apr 11, 2026
? (part.input ??
('rawInput' in part ? part.rawInput : undefined))
: part.input,
: (part.input ?? {}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The output-error branch in convert-to-model-messages.ts can produce undefined for the tool-call input field when both part.input and part.rawInput are undefined, causing OpenAI to reject the request with "Missing required param".

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 ai/ui anything UI related 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.

BUG: convertToModelMessages omits input on tool-call parts when input is undefined, causing OpenAI "Missing required parameter: arguments" error

1 participant