Skip to content

fix(openai): send content: null instead of empty string for tool-call-only assistant messages#12605

Open
giulio-leone wants to merge 2 commits intovercel:mainfrom
giulio-leone:fix/issue-12389-content-empty-string-null
Open

fix(openai): send content: null instead of empty string for tool-call-only assistant messages#12605
giulio-leone wants to merge 2 commits intovercel:mainfrom
giulio-leone:fix/issue-12389-content-empty-string-null

Conversation

@giulio-leone
Copy link

Fixes #12389

Problem

convertToOpenAIChatMessages sends content: "" for assistant messages with only tool calls. Per OpenAI spec, it should be content: null.

Impact

OpenAI-compatible providers (Ollama, etc.) switch from structured tool_calls to text markup when they see content: "" in history.

Fix

Changed content: text to content: text || null - sends null when no text content exists.

giulio-leone and others added 2 commits February 14, 2026 22:05
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@giulio-leone giulio-leone force-pushed the fix/issue-12389-content-empty-string-null branch from 23649d6 to 373edf3 Compare February 14, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

convertToOpenAIChatMessages sends content: "" instead of content: null for tool-call-only assistant messages

1 participant