fix: use placeholder for empty tool result content to fix Gemini API validation #10672
+74
−1
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 Gemini API validation error where empty tool result content causes "Unable to submit request because it must include at least one parts field" error.
Problem
Users were encountering an
ApiProviderErrorwhen using Gemini models via OpenRouter because tool result messages with empty content fail Gemini's validation requirements.Root Cause
While most tool execution paths add fallback content, empty content can still reach the API from:
processToolContentreturns "" for empty results)Solution
Applied a defensive fix at the transformation layer in
src/api/transform/openai-format.ts:This is the correct location because:
Testing
PostHog Reference
https://us.posthog.com/error_tracking/019bb191-73dd-7471-8079-4723c6b2efa0
Closes ROO-517
Important
Fixes Gemini API validation by using "(empty)" placeholder for empty tool result content in
convertToOpenAiMessages()inopenai-format.ts.convertToOpenAiMessages()inopenai-format.ts.openai-format.spec.ts.openai-format.spec.tspass.This description was created by
for 5ef90c7. You can customize this summary. It will automatically update as commits are pushed.