Skip to content

Fix Custom Gemini 3.X Models#199

Closed
nzoschke wants to merge 2 commits intoboldsoftware:mainfrom
nzoschke:nzoschke/gemini-thinking-config
Closed

Fix Custom Gemini 3.X Models#199
nzoschke wants to merge 2 commits intoboldsoftware:mainfrom
nzoschke:nzoschke/gemini-thinking-config

Conversation

@nzoschke
Copy link
Copy Markdown
Contributor

@nzoschke nzoschke commented May 3, 2026

Currently adding Google Gemini model gemini-2.5-pro works fine, but gemini-3.1-pro-preview fails the test with Test failed: empty response from model.

This is due to a change the Gemini API for 3.x attaching thoughtSignature to final answer text parts, not just thought summaries, which Shelley converts to an empty Text response.

  • Add the missing thought boolean to gemini.Part and classify on it
  • Preserve thoughtSignature on outgoing ContentTypeText so cache state survives the round trip
  • Set thought=true on outgoing Thinking/RedactedThinking parts
  • Update existing tests that encoded the old assumption; add regression test

Patch and parts of this PR description generated by Claude Code / Opus 4.7

The gem.Service was ignoring the reasoning_effort column entirely: 3.x
models defaulted to "high" silently, and 2.5 models had no way to set
thinking_budget. Now ThinkingLevel/ReasoningEffort map to thinkingLevel
(3.x string) or thinkingBudget (2.5 int), matching how oai.ResponsesService
plumbs the same field. Also adds the gemini-3.1 preview models to the
context-window switch.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented May 3, 2026

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: exe.dev user.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

…ature presence

Gemini 3.x attaches thoughtSignature to ordinary final-answer text parts
to round-trip encrypted reasoning state, not just to thought summaries.
convertGeminiResponseToContent was treating any text with a signature as
ContentTypeThinking, hiding the actual answer — every Gemini 3 turn
produced an empty Text response, and "Test" against gemini-3.x failed
with "empty response from model".

Add the missing thought boolean to gemini.Part and classify on it.
Preserve thoughtSignature on outgoing ContentTypeText so cache state
survives the round trip, and set thought=true on outgoing
Thinking/RedactedThinking parts. Update the existing tests that encoded
the old assumption and add a regression test for the bug.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@nzoschke nzoschke force-pushed the nzoschke/gemini-thinking-config branch from 28865e6 to 255bc2a Compare May 3, 2026 16:40
@cla-bot cla-bot Bot added the cla-signed label May 3, 2026
@nzoschke
Copy link
Copy Markdown
Contributor Author

nzoschke commented May 6, 2026

More QA on this. Anthropic API is down so I'm trying to cut over to Gemini.

With Shelley out of the box I can't pass the "test" for a custom Gemini model, it returns Test failed: empty response from model

Screenshot 2026-05-06 at 9 15 12 AM

Replacing shelley with my branch, "test" passes and conversations work

Screenshot 2026-05-06 at 9 27 40 AM Screenshot 2026-05-06 at 9 29 52 AM

@philz
Copy link
Copy Markdown
Contributor

philz commented May 6, 2026

I pushed these outside of the PR process. THANK YOU!

@philz philz closed this May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants