You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(vertex): @ai-sdk/google-vertex serializer emits empty model parts: [] on empty reasoning turns (missed by #30463) #47863
When using Google Gemini models on Vertex AI (google-vertex), requests intermittently fail with HTTP 400:
Unable to submit request because it must include at least one parts field, which describes the prompt input. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini
Once this happens, every subsequent prompt in that session fails because the stored history contains the empty-parts turn.
Root cause
PR #30463 added patches/@ai-sdk%[email protected] to omit empty model turns (if (contents[contents.length - 1].parts.length === 0) contents.pop()).
When a Gemini model (such as gemini-3.8-flash) emits an initial step-start followed by an empty reasoning chunk (text: "") before another step-start or tool call:
convertToModelMessages splits on step-start, producing an assistant message with only { type: "reasoning", text: "" }.
When serialized for Vertex AI via @ai-sdk/[email protected], part.text.length === 0 is filtered to undefined, yielding parts: [].
Without the contents.pop() guard, { role: "model", parts: [] } is sent to Vertex AI, which rejects it with HTTP 400.
Additionally, message-v2.ts does not filter zero-length reasoning parts in toModelMessagesEffect when replaying history.
OpenCode version
1.18.28 / dev
Steps to reproduce
Configure google-vertex provider with a thinking Gemini model (e.g. gemini-3.8-flash).
Run a session where a turn starts with an empty reasoning chunk before tool execution (persisting a reasoning part with text: "").
Send any subsequent prompt.
Vertex AI rejects the request with HTTP 400 (Unable to submit request because it must include at least one parts field).
Activity
rekram1-node commentedon Oct 8, 2026
This is fixed on v2:
https://opencode.ai/v2/docs