Repository navigation
fix(v2): support session-bound generation and text JSON for google - #540
Merged
EyJunge1 merged 1 commit intoDec 4, 2026
Merged
Conversation
Prefer real capture sessions with session.generate for providers that abort on the sessionless Generate API, and route google/* through the text-JSON structured-output path.
EyJunge1
force-pushed
the
fix/v2-google-gemini-structured-output
branch
from
December 4, 2026 08:55
8511263 to
fd0601d
Compare
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.
Problem
When using OpenCode V2 with Google Workspace / Vertex authentication (via
opencode-gemini-author native Google providers), auto-capture fails on idle sessions with repeated errors:Root Cause
In src/v2/legacy-client.ts, ctx.generate.text targets OpenCode's stateless /api/experimental/generate endpoint. Google/Gemini streaming responses close the connection immediately upon completion, causing the server endpoint to abort with 503 Service Unavailable: "The provider response ended unexpectedly.".
However, OpenCode V2's session-bound generation endpoint (ctx.session.generate({ sessionID, prompt })) manages connection lifecycle within a persistent session context and handles Google SSE streams reliably (200 OK).
In OpenCode V2, client.session.prompt requires a top-level text field in addition to parts. Omitting text triggers an InvalidRequestError: Missing key at ["text"].
Similar to Anthropic models (issue Auto capute not working through claude code #278), Google/Gemini providers under OpenCode output markdown JSON blocks rather than OpenAI-style forced JSON schema tool calls. Enforcing format: json_schema can cause the stream to stall or abort.
Solution
Verification