Skip to content

fix(gemini): reasoning_effort="none" disables thinking instead of hiding it - #5

Merged
JamMaster1999 merged 1 commit into
mainfrom
fix/gemini-reasoning-none-disables-thinking
Aug 16, 2026
Merged

JamMaster1999 merged 1 commit into
mainfrom
fix/gemini-reasoning-none-disables-thinking

Conversation

@JamMaster1999

@JamMaster1999 JamMaster1999 commented Aug 16, 2026 •

Copy link
Copy Markdown
Owner

Description

reasoning_effort="none" (and None) currently maps to ThinkingConfig(include_thoughts=False), which hides thought summaries instead of turning off thinking.

"none" already means off everywhere else in this codebase:

  • anthropic sends thinking={"type": "disabled"},
  • cohere and deepseek send their disable flags,
  • ollama sends think=False,
  • messages_compat.py maps Anthropic's disabled back to reasoning_effort="none".

Gemini is the one provider where "none" means "hide but keep billing".

The fix, per path:

Why clamp with warning, instead of error?

On 3.5/3.6 the clamp billed zero thought tokens (table below), so "none" callers get what they asked for. Erroring up front instead would mean guessing from the version string which models those are, the kind of guess mozilla-ai#1189 declined. A model that doesn't support MINIMAL rejects it, and the caller gets the typed 400 (3.7, note below).

The warning is because MINIMAL is the least thinking the model allows, not a promise of zero, and mozilla-ai#1107 treats surprise thinking costs as a bug.

None stays merged with "none" as it has been since mozilla-ai#708; "auto" remains the unset default, so callers who don't set the parameter are untouched.

Verified live across every path with reasoning_effort="none" (gap = thought tokens billed but hidden; before the fix, gemini-2.5-flash billed 424 hidden thought tokens):

gemini models path result
2.5-flash, 2.5-flash-lite, 3-flash-preview, 3.1-flash-lite budget → 0 OK, gap 0
2.5-pro, 3.1-pro-preview budget → 0, rejected typed InvalidRequestError: "Budget 0 is invalid. This model only works in thinking mode."
3.5-flash, 3.5-flash-lite, 3.6-flash level → MINIMAL OK, gap 0, warning emitted
3.7-flash level → MINIMAL, rejected typed InvalidRequestError: "Thinking level MINIMAL is not supported", details below

Every failure surfaces as a typed any-llm exception; no raw google.genai errors leak.

Why gemini-3.7-flash rejects the clamp

gemini-3.7-flash cannot disable thinking: MINIMAL is gone, the new floor LOW thinks for real (220 thought tokens on the test prompt), and thinking_budget=0 is silently ignored but still billed. So the 400 is correct, same as the thinking-only pros, and clamping to LOW would just bring back the bug this PR fixes. The removal also breaks the existing "minimal" mapping (mozilla-ai#1281) on 3.7.

For reference, thinking_budget=0 today is honored on 3.5, rejected on 3.6, and ignored-and-billed on 3.7. Three behaviors in three consecutive minor versions is why this PR trusts the SDK enum and provider errors instead of a model matrix.

Behavior change

reasoning_effort="none" previously kept thinking active (billed, hidden); it now genuinely disables it. Models that cannot run without thinking now raise Google's 400 instead of silently billing. Callers who relied on "hidden but active" thinking should use "auto" or a graded level. Default ("auto") behavior is unchanged.

PR Type

  • 🐛 Bug Fix

Relevant issues

Fixes #2 (staged on this fork; re-pointed to the upstream issue number at submission)

Checklist

  • I understand the code I am submitting.
  • I have added unit tests that prove my fix/feature works
  • I have run this code locally and verified it fixes the issue.
  • New and existing tests pass locally
  • Documentation was updated where necessary (not applicable)
  • I have read and followed the contribution guidelines
  • AI Usage:
    • No AI was used.
    • AI was used for drafting/refactoring.
    • This is fully AI-generated.

AI Usage Information

  • AI Model used: Claude (Fable 5)

  • AI Developer Tool used: Claude Code

  • Any other info you'd like to share:

  • I am an AI Agent filling out this form (check box if true)

@JamMaster1999
JamMaster1999 merged commit 13de2d0 into main Aug 16, 2026
@JamMaster1999

Copy link
Copy Markdown
Owner Author

Submitted upstream as mozilla-ai#1294

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.

[BUG] Gemini: reasoning_effort="none" hides thoughts instead of disabling thinking

1 participant