[GH-ISSUE #7558] Gemini requests on OpenRouter and Gemini 3.6+ Flash: final AI turn, penalties, tool-round thoughts #4202

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

Originally created by @SpicyMarinara on GitHub (Oct 13, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7558

Originally assigned to: @SpicyMarinara on GitHub.

An audit of how Gemini requests are built (on staging 27b4cc004, using stubbed requests only) found six gaps. Native Google AI Studio and Vertex requests for Gemini 4 Argon are fine. Most of the gaps are on OpenRouter and the other OpenAI-compatible connections, or affect the newer Gemini Flash models.

1. A request can end on an AI turn on OpenRouter, NanoGPT and custom connections (major)
With google/gemini-4-argon on OpenRouter:

  • a preset with an Assistant Prefill, or
  • pressing Send with an empty box after an AI reply in Roleplay

sends a request whose last message is the assistant's. Google says Argon rejects that: "History payloads can't end with a model role turn" (https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/guides/gemini-4-argon). Native Google and Vertex already add a short user turn asking the model to continue. The OpenAI-compatible path only does this for Claude Opus 5.5 and Sonnet 5.5.

2. Gemini 3.5 Flash-Lite and 3.6, 3.7 and 3.8 Flash have the same rules as Argon but none of its handling (major)
Google documents two rules for these models. A request that ends on a model turn is rejected, and so are frequency and presence penalties:

Marinara checks only for Argon, so a prefill, an empty Send after a reply, or any penalty setting fails on every connection type.

3. OpenRouter Gemini tool rounds lose the model's reasoning details (major)
When a Gemini model on OpenRouter calls a tool, the next request replays that call without the reasoning_details OpenRouter returned with it. Those details carry Gemini's thought signatures. OpenRouter says to pass them back unmodified during tool calling (https://openrouter.ai/docs/guides/best-practices/reasoning-tokens). Without them, Gemini 3 has been reported to return 400. Stored chat history must stay filtered so #1097 stays fixed.

4. Post-Processing = Don't Apply sends system messages mid-chat to Gemini on OpenRouter (minor)
Depth sections, the author's note and post-history sections go out as system messages in the middle of the chat. OpenRouter does not document how it passes these to Gemini. A third-party report says only the last one is kept (https://github.com/pipecat-ai/pipecat/issues/3362), which could drop the main prompt and the character card.

5. The Argon code comment cites a page without the prefill or penalty rules (minor)
isGeminiArgonModel cites https://ai.google.dev/gemini-api/docs/models/gemini-4-argon. The rules are in the Vertex guide: https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/guides/gemini-4-argon

6. Native chat drops an AI turn that has saved Gemini parts but no text (minor)
On Google AI Studio and Vertex, chat() skips a past assistant message whose saved Gemini parts hold only thoughts or a signature. The tools path keeps such a message. This is rare.

Originally created by @SpicyMarinara on GitHub (Oct 13, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7558 Originally assigned to: @SpicyMarinara on GitHub. An audit of how Gemini requests are built (on staging 27b4cc004, using stubbed requests only) found six gaps. Native Google AI Studio and Vertex requests for Gemini 4 Argon are fine. Most of the gaps are on OpenRouter and the other OpenAI-compatible connections, or affect the newer Gemini Flash models. **1. A request can end on an AI turn on OpenRouter, NanoGPT and custom connections (major)** With `google/gemini-4-argon` on OpenRouter: - a preset with an Assistant Prefill, or - pressing Send with an empty box after an AI reply in Roleplay sends a request whose last message is the assistant's. Google says Argon rejects that: "History payloads can't end with a `model` role turn" (https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/guides/gemini-4-argon). Native Google and Vertex already add a short user turn asking the model to continue. The OpenAI-compatible path only does this for Claude Opus 5.5 and Sonnet 5.5. **2. Gemini 3.5 Flash-Lite and 3.6, 3.7 and 3.8 Flash have the same rules as Argon but none of its handling (major)** Google documents two rules for these models. A request that ends on a model turn is rejected, and so are frequency and presence penalties: - https://ai.google.dev/gemini-api/docs/whats-new-gemini-3.6 - https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/guides/gemini-3-6-flash - https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/guides/gemini-3-7-flash - https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/guides/gemini-3-8-flash - https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-5-flash-lite Marinara checks only for Argon, so a prefill, an empty Send after a reply, or any penalty setting fails on every connection type. **3. OpenRouter Gemini tool rounds lose the model's reasoning details (major)** When a Gemini model on OpenRouter calls a tool, the next request replays that call without the `reasoning_details` OpenRouter returned with it. Those details carry Gemini's thought signatures. OpenRouter says to pass them back unmodified during tool calling (https://openrouter.ai/docs/guides/best-practices/reasoning-tokens). Without them, Gemini 3 has been reported to return 400. Stored chat history must stay filtered so #1097 stays fixed. **4. Post-Processing = Don't Apply sends system messages mid-chat to Gemini on OpenRouter (minor)** Depth sections, the author's note and post-history sections go out as `system` messages in the middle of the chat. OpenRouter does not document how it passes these to Gemini. A third-party report says only the last one is kept (https://github.com/pipecat-ai/pipecat/issues/3362), which could drop the main prompt and the character card. **5. The Argon code comment cites a page without the prefill or penalty rules (minor)** `isGeminiArgonModel` cites https://ai.google.dev/gemini-api/docs/models/gemini-4-argon. The rules are in the Vertex guide: https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/guides/gemini-4-argon **6. Native chat drops an AI turn that has saved Gemini parts but no text (minor)** On Google AI Studio and Vertex, `chat()` skips a past assistant message whose saved Gemini parts hold only thoughts or a signature. The tools path keeps such a message. This is rare.
bsakaguchi 2026-10-21 06:12:22 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Oct 13, 2026):

Fixed on staging by #7560. Two minor follow-ups from review (regenerating a user message, and Individual group turns, on OpenRouter/NanoGPT/custom Gemini) are being fixed in a follow-up PR.

<!-- gh-comment-id:6153586236 --> @SpicyMarinara commented on GitHub (Oct 13, 2026): Fixed on staging by #7560. Two minor follow-ups from review (regenerating a user message, and Individual group turns, on OpenRouter/NanoGPT/custom Gemini) are being fixed in a follow-up PR.
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#4202
No description provided.