fix(provider): patch empty Gemini replay messages for Vertex AI - #47864
Open
ghchinoy wants to merge 1 commit into
Open
fix(provider): patch empty Gemini replay messages for Vertex AI#47864ghchinoy wants to merge 1 commit into
ghchinoy wants to merge 1 commit into
Conversation
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.
Issue for this PR
Closes #47863
Type of change
What does this PR do?
PR #30463 patched
@ai-sdk/google@3.0.73to pop empty model turns (if (contents[contents.length - 1].parts.length === 0) contents.pop()). However,@ai-sdk/google-vertexdepends on@ai-sdk/google@3.0.108inbun.lock, which was not covered by the 3.0.73 patch rule. As a result, Gemini on Vertex AI (google-vertex) still emitted{ role: "model", parts: [] }when an assistant turn contained only empty reasoning parts (text: ""), resulting in HTTP 400 (Unable to submit request because it must include at least one parts field).This PR:
patches/@ai-sdk%2Fgoogle@3.0.108.patchto apply the samecontents.pop()guard to@ai-sdk/google@3.0.108used by@ai-sdk/google-vertex.MessageV2.toModelMessagesEffect(packages/opencode/src/session/message-v2.ts) to skip zero-length reasoning parts when replaying history.packages/opencode/test/session/llm.test.tscoveringgoogle-vertexpayload construction with empty reasoning parts.How did you verify your code works?
bun test test/session/llm.test.ts -t "sends Google": bothgoogleandgoogle-vertextests pass.bun turbo typecheck(all 30 package tasks passed).Screenshots / recordings
N/A (backend/protocol fix)
Checklist