Skip to content

fix(ai): continue Google Interactions responses split across requests - #65006

Merged
rekram1-node merged 2 commits into
devfrom
interactions-continuation
Nov 19, 2026
Merged

rekram1-node merged 2 commits into
devfrom
interactions-continuation

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

None.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

I made Google Interactions continue the same response when Google asks for another request.

- Google splits the response → OpenCode stops reading
+ Google splits the response → POST with its token → one response and finish

Text, reasoning, signed tool calls, and usage carry across requests. I matched Google's GenAI SDKs: there is no total hop cap, a hop that finishes with its starting token stops, and a dropped stream gets up to three reconnects without a new token. New tokens reset that count. Output after the checkpoint or an HTTP rejection goes through the existing retry path.

How did you verify your code works?

I ran the Google Interactions tests (29 passed), AI typecheck, changed-file lint, and the root check. Live Flash returned incomplete at a low cap. Neon finished below its hop limit, so neither returned a token. The continuation tests use scripted SSE in Google's documented format.

Screenshots / recordings

Not applicable.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Public API: adds GoogleInteractions.transport and Prepared exports to @opencode/ai/protocols (backwards compatible)

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found no problems that should block this merge. The continuation logic matches Google's documented requires_continuation / continuation_token flow and the official Python SDK's handling. With store on it sends previous_interaction_id set to the interaction that issued the token and leaves out input; with store off it resends the input. Resuming a dropped stream is limited to checkpoints with no visible output after them, which avoids repeating text or tool calls.

I couldn't test against a live Google model. Instead I ran the new tests on the base branch, where 5 of the 7 continuation cases fail (one hangs until its timeout). With this PR all 13 tests in google-interactions.test.ts pass, and tsc --noEmit passes for packages/ai.

Public API: additive only. GoogleInteractions.transport and the Prepared type are new exports from @opencode/ai/protocols. For responses split across requests, the Google usage providerMetadata now holds per-request sums plus a requests count. Single-request responses are unchanged, so this is backwards compatible.

@rekram1-node
rekram1-node enabled auto-merge (squash) November 19, 2026 23:19

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit is sound; I have nothing new to raise. Follow-up requests now require a new token, and a completed request that returns its own start token stops as an incomplete stream, so it can't loop. A dropped stream gets up to three reconnects without a new token, using the interaction that issued the token, and each new token resets that count. After the third reconnect, the last disconnect is reported as a retryable incomplete-stream error. HTTP errors on follow-up requests go to the existing retry handling. This matches Google's SDK behaviour.

I checked it with scripted streams only (no live Google model): all 16 tests in google-interactions.test.ts pass, and tsc --noEmit passes for packages/ai.

Public API: unchanged since the last review. It adds the GoogleInteractions.transport and Prepared exports to @opencode/ai/protocols, which is backwards compatible.

@rekram1-node
rekram1-node merged commit d20509d into dev Nov 19, 2026
12 checks passed
@rekram1-node
rekram1-node deleted the interactions-continuation branch November 19, 2026 23:26
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant