[GH-ISSUE #5904] Gemini reasoning turns never stream because a proxy workaround is applied to every connection #3261

Closed
opened 2026-10-21 06:01:27 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Sep 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5904

Originally assigned to: @SpicyMarinara on GitHub.

When a Gemini connection has reasoning enabled, no turn ever streams. The provider
forces the buffered generateContent endpoint whenever a thinking config is present —
useStreaming = options.stream && !thinkingConfig
(packages/server/src/services/llm/providers/google.provider.ts:691-694) — so the
user watches a silent screen for the whole generation and then gets the entire reply
at once. Reasoning turns are the longest turns a model produces, so the buffering
lands exactly where streaming matters most; a long thinking turn with no tokens
arriving is indistinguishable from a hang.

Where it comes from, and why it exists. The comment above the line says it plainly:
"proxies like linkapi.ai strip thought parts from SSE streams but return them in
non-streaming responses." Thought parts matter beyond display — the provider stores a
model turn's Gemini parts, including thought signatures, and replays them on later
turns to preserve reasoning state (google.provider.ts:708-712), so a stream that
silently drops them degrades every subsequent turn of the chat. For a user on one of
those proxies, the buffering is genuinely the right call.

The problem is the scope. The workaround is applied to every connection,
unconditionally. A user pointed directly at generativelanguage.googleapis.com —
where the streaming endpoint returns thought parts correctly — pays the same
full-generation buffering as a user behind a thought-stripping proxy. The engine
already knows proxies are common here (normalizeGoogleGenerativeLanguageBaseUrl
exists precisely to fix up proxy base URLs), but it never distinguishes them from the
official endpoint.

Why it matters to a user. Reasoning is a per-connection setting someone deliberately
turns on to get better answers; the hidden price today is that their app stops
feeling alive on every turn. Nothing in the UI explains it, so the natural readings
are "Gemini is slow" or "the app is stuck" — a support burden shaped exactly like a
bug report, for behavior that is actually a compatibility choice made on behalf of a
proxy the user may not even use.

The smallest honest fix is to scope the workaround rather than remove it. Several
shapes would do it, each with a real tradeoff worth weighing: a per-connection
"proxy compatibility" setting (explicit, but one more knob to explain); defaulting by
endpoint (stream when the base URL is the official Google endpoint, buffer for
anything unrecognized — zero-knob, but wrong for a well-behaved proxy); or optimistic
streaming with sticky fallback (stream the turn, and if expected thought parts come
back missing, warn once and buffer subsequent thinking turns on that connection —
self-correcting, but the first turn on a stripping proxy loses its thought parts).
Whichever lands, the in-progress provider streaming-with-tools work deliberately
inherits today's rule untouched, so both paths should pick up the scoping from this
issue rather than each inventing their own.

Originally created by @kolacheee on GitHub (Sep 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5904 Originally assigned to: @SpicyMarinara on GitHub. When a Gemini connection has reasoning enabled, no turn ever streams. The provider forces the buffered `generateContent` endpoint whenever a thinking config is present — `useStreaming = options.stream && !thinkingConfig` (`packages/server/src/services/llm/providers/google.provider.ts:691-694`) — so the user watches a silent screen for the whole generation and then gets the entire reply at once. Reasoning turns are the longest turns a model produces, so the buffering lands exactly where streaming matters most; a long thinking turn with no tokens arriving is indistinguishable from a hang. Where it comes from, and why it exists. The comment above the line says it plainly: "proxies like linkapi.ai strip thought parts from SSE streams but return them in non-streaming responses." Thought parts matter beyond display — the provider stores a model turn's Gemini parts, including thought signatures, and replays them on later turns to preserve reasoning state (`google.provider.ts:708-712`), so a stream that silently drops them degrades every subsequent turn of the chat. For a user on one of those proxies, the buffering is genuinely the right call. The problem is the scope. The workaround is applied to every connection, unconditionally. A user pointed directly at `generativelanguage.googleapis.com` — where the streaming endpoint returns thought parts correctly — pays the same full-generation buffering as a user behind a thought-stripping proxy. The engine already knows proxies are common here (`normalizeGoogleGenerativeLanguageBaseUrl` exists precisely to fix up proxy base URLs), but it never distinguishes them from the official endpoint. Why it matters to a user. Reasoning is a per-connection setting someone deliberately turns on to get better answers; the hidden price today is that their app stops feeling alive on every turn. Nothing in the UI explains it, so the natural readings are "Gemini is slow" or "the app is stuck" — a support burden shaped exactly like a bug report, for behavior that is actually a compatibility choice made on behalf of a proxy the user may not even use. The smallest honest fix is to scope the workaround rather than remove it. Several shapes would do it, each with a real tradeoff worth weighing: a per-connection "proxy compatibility" setting (explicit, but one more knob to explain); defaulting by endpoint (stream when the base URL is the official Google endpoint, buffer for anything unrecognized — zero-knob, but wrong for a well-behaved proxy); or optimistic streaming with sticky fallback (stream the turn, and if expected thought parts come back missing, warn once and buffer subsequent thinking turns on that connection — self-correcting, but the first turn on a stripping proxy loses its thought parts). Whichever lands, the in-progress provider streaming-with-tools work deliberately inherits today's rule untouched, so both paths should pick up the scoping from this issue rather than each inventing their own.
bsakaguchi 2026-10-21 06:01:27 +07:00
  • closed this issue
  • added the
    in-pr
    label
Author
Owner

@SpicyMarinara commented on GitHub (Sep 8, 2026):

Codex is taking #5904 for @SpicyMarinara in the assigned-issue sweep. The staging fix will scope the existing reasoning-buffer workaround to proxy endpoints and keep both ordinary and tool-calling Gemini turns on the same policy. No extra user setting is needed.

<!-- gh-comment-id:5592247533 --> @SpicyMarinara commented on GitHub (Sep 8, 2026): Codex is taking #5904 for @SpicyMarinara in the assigned-issue sweep. The `staging` fix will scope the existing reasoning-buffer workaround to proxy endpoints and keep both ordinary and tool-calling Gemini turns on the same policy. No extra user setting is needed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3261
No description provided.