This repository was archived by the owner on May 15, 2026. It is now read-only.
fix: ensure assistant message content is never undefined for Gemini compatibility - #10559
Merged
mrubens merged 1 commit intoJan 9, 2026
Conversation
…ompatibility When assistant messages contain only tool_use blocks (no text), the content field was left as undefined. While OpenAI accepts content: null with tool_calls, Gemini (via OpenRouter) strictly requires every message to have content. Changes: - Use empty string fallback for assistant message content when undefined - Add test case for Gemini compatibility Fixes ROO-425
mrubens
approved these changes
Jan 8, 2026
Review complete. No issues found. The fix correctly uses Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
ghost
approved these changes
Jan 8, 2026
mrubens
deleted the
feature/roo-425-openrouter-gemini-parts-field-validation-error
branch
January 9, 2026 01:32
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 ROO-425: OpenRouter + Gemini "parts field" validation error when assistant message has undefined content.
Problem
When assistant messages contain only
tool_useblocks (no text), thecontentfield was left asundefined. While OpenAI acceptscontent: nullwithtool_calls, Gemini (via OpenRouter) strictly requires every message to have content in the "parts" field.This caused users to encounter a 400 Bad Request error:
Solution
Use empty string fallback (
content ?? "") for assistant message content instead of allowingundefined.Changes
src/api/transform/openai-format.ts: Usecontent ?? ""instead ofcontentsrc/api/transform/__tests__/openai-format.spec.ts: Add test case for Gemini compatibilityTesting
openai-format.spec.tsRelated
Important
Fixes undefined content in assistant messages for Gemini compatibility by using empty string fallback in
convertToOpenAiMessages().tool_useblocks hadundefinedcontent, causing errors with Gemini via OpenRouter.content ?? ""to ensure content is neverundefinedinconvertToOpenAiMessages()inopenai-format.ts.openai-format.spec.tsto verify empty string content for Gemini compatibility.openai-format.spec.tsand across the project.This description was created by
for f6304d4. You can customize this summary. It will automatically update as commits are pushed.