Description
When using Google Vertex AI (Gemini Flash preview models), opencode works initially at the beginning of a session but eventually crashes with a Vertex API error during active use (e.g., when building something or running tool commands).
Attempting to fork or create a new session from this state still results in the same error, suggesting that an empty string or malformed message object is being permanently saved to the context/history.
Error Message:
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
Expected Behavior:
The request should succeed. If a tool execution or model generation results in an empty output, opencode should handle it gracefully by padding the response or stripping the empty message before sending it to the Vertex API.
Actual Behavior:
The tool crashes because Vertex AI API strictly rejects empty parts arrays or content: null/"" messages, which are currently being appended to the conversation history.
Possible Root Cause:
This is a common issue when using OpenAI-style message formatting layers with Google Vertex AI.
- Vertex AI throws a 400 error if any message in the history contains an empty parts array.
- This usually happens if an execution command returns an empty string (no standard output), or if an assistant tool call returns content: null.
- Suggested Fix: Before sending the messages payload to the Vertex API, check for and sanitize empty parts/contents (e.g., replace an empty tool response string with "Command executed successfully with no output").
OpenCode version
1.2.26
Steps to reproduce
- Configure opencode to use Google Vertex AI with a Gemini Flash preview model.
- Start a new session and give an initial prompt (works as expected).
- Have the assistant start building something, reading files, or executing tool commands.
- Eventually, the request fails with the "must include at least one parts field" error.
- Try to fork or restart the session with the same context; the error persists.
Operating System
MacOS
Terminal
Ghostty
Description
When using Google Vertex AI (Gemini Flash preview models), opencode works initially at the beginning of a session but eventually crashes with a Vertex API error during active use (e.g., when building something or running tool commands).
Attempting to fork or create a new session from this state still results in the same error, suggesting that an empty string or malformed message object is being permanently saved to the context/history.
Error Message:
Expected Behavior:
The request should succeed. If a tool execution or model generation results in an empty output, opencode should handle it gracefully by padding the response or stripping the empty message before sending it to the Vertex API.
Actual Behavior:
The tool crashes because Vertex AI API strictly rejects empty parts arrays or content: null/"" messages, which are currently being appended to the conversation history.
Possible Root Cause:
This is a common issue when using OpenAI-style message formatting layers with Google Vertex AI.
OpenCode version
1.2.26
Steps to reproduce
Operating System
MacOS
Terminal
Ghostty