Skip to content

fix: use thinking levels for Gemini 4 small calls - #1534

Merged
anandgupta42 merged 3 commits into
mainfrom
fix/gemini4-small-thinking
Oct 17, 2026
Merged

anandgupta42 merged 3 commits into
mainfrom
fix/gemini4-small-thinking

Conversation

@anandgupta42

@anandgupta42 anandgupta42 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #1533

Type of change

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

What does this PR do?

Why: every small model call fails on Gemini 4 models (gemini-4-argon and newer) on Google and Vertex. That covers session titles, prompt enhancement, project copy and any tool that uses the small-call path. Streaming callers then report only "No output generated".

Root cause: ProviderTransform.smallOptions sent thinkingConfig: { thinkingBudget: 0 } to every Google reasoning model except Gemini 3. Gemini 4 rejects thinking budgets:

400 Thinking budget is not supported for this model. Use thinking level instead.

What changed: the small-call thinking control is now chosen by Gemini generation, inside the existing upstream_fix marker:

Model Before After
Gemini 2.x, unversioned aliases (e.g. gemini-flash-latest) thinkingBudget: 0 unchanged
Gemini 3 / 3.1 thinkingLevel: "minimal" unchanged
Gemini 4+ thinkingBudget: 0 → 400 lowest configured supported level, else "low"

Non-Google providers are untouched.

Tenant/user impact: users on Gemini 4 models get working small calls (titles, prompt enhancement). No change for other models.

Deployment readiness: self-contained.

How did you verify your code works?

  • Live provider: a direct Vertex AI call to gemini-4-argon with each config. thinkingBudget: 0 returned the 400 above, and thinkingLevel: "low" returned a normal response.
  • Unit: test/provider/transform.test.ts has new cases for Google and Vertex covering Gemini 2.0, 2.5, 3, 3.1, 4, 5 and 30 plus an unversioned alias, with and without generated variants, and lowest-level selection from custom variants. 356 pass, 0 fail.
  • bun run typecheck is clean.

Screenshots / recordings

Not applicable. There are no UI changes.

Checklist

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

🤖 Generated with Claude Code


Note

Low Risk
Narrow change to small-call provider options for Google reasoning models, with broad unit test coverage and no auth or data-path impact.

Overview
Fixes broken small Google/Vertex reasoning calls on Gemini 4+, where ProviderTransform.smallOptions still sent thinkingConfig: { thinkingBudget: 0 } and the API returned 400 (“use thinking level instead”). Session titles, prompt enhancement, and other lightweight paths that use smallOptions were failing with no output.

smallOptions now picks thinking controls from the parsed Gemini generation in model.api.id (including prefixed/Vertex-style ids): Gemini 3 keeps thinkingLevel: "minimal"; Gemini 2.x and unversioned aliases keep thinkingBudget: 0; Gemini 4+ uses thinkingLevel, preferring the lowest configured level from model variants (low → medium → high), defaulting to "low". OpenAI and other providers are unchanged.

Tests in transform.test.ts cover Google and Vertex across Gemini 2.0–5, edge id shapes, empty vs generated variants, and lowest-level selection for Gemini 4 custom variants.

Reviewed by Cursor Bugbot for commit 3d7f63e. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Fixes #1533: small model calls (session titles, prompt enhancement, project copy) now work on Gemini 4 models on Google and Vertex, which previously rejected the thinkingBudget: 0 setting with a 400 error.

  • Chooses the thinking control by parsing the Gemini generation from any gemini-<N> id form, so prefixed or concatenated ids like vertex_gemini-4argon are handled correctly along with plain, dated, and unversioned aliases.
  • Gemini 2.x and unversioned aliases keep thinkingBudget: 0, Gemini 3 keeps thinkingLevel: "minimal", and Gemini 4+ uses the lowest configured supported thinking level, falling back to low.
  • Adds unit tests for Google and Vertex covering Gemini 2.0, 2.5, 3, 3.1, 4, 5, and 30 including path-prefixed and concatenated id forms.

Written for commit 3d7f63e. Summary will update on new commits.

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • Bug Fixes
    • Improved reasoning configuration for Google Gemini models across generations. Gemini 2.x models and unversioned aliases use no thinking budget, while Gemini 3 uses minimal thinking. Gemini 4 and later use the lowest configured thinking level—low, medium, or high—and default to low when no level is configured. These settings apply consistently across Google and Vertex models.

`smallOptions` gave every Google reasoning model except Gemini 3
`thinkingBudget: 0`. Gemini 4 rejects budgets with a 400 ("Thinking budget is
not supported for this model. Use thinking level instead."), so every small
call (session title, prompt enhancement, project copy) failed on it.

- Gemini 2.x and unversioned aliases keep `thinkingBudget: 0`; Gemini 3 keeps
  `thinkingLevel: "minimal"`; Gemini 4+ uses the lowest configured supported
  level, falling back to `low`.
- Tests cover Google and Vertex for 2.0/2.5/3/3.1/4/5/30 and an unversioned
  alias, with and without generated variants.

Closes #1533

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 17, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 61a1331b-89d3-42dd-a38d-d3f84763d5ce)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T02:52:25.547100Z 3d7f63e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 48c6b4c2-1cd4-423f-a4d2-bcd9823990ee
📥 Commits

Reviewing files that changed from the base of the PR and between 380beb3 and 3d7f63e.

📒 Files selected for processing: 2
  • packages/opencode/src/provider/transform.ts
  • packages/opencode/test/provider/transform.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

📝 Walkthrough

smallOptions now selects Google and Vertex Gemini thinking controls by model generation. Tests cover Gemini 2.x, Gemini 3, and Gemini 4+ model IDs, including selection of the lowest configured thinking level.

Changes: Gemini small-call configuration

Layer / File(s) Summary
Select thinking controls by generation
packages/opencode/src/provider/transform.ts, packages/opencode/test/provider/transform.test.ts
Gemini 3 uses minimal thinking. Gemini 2.x and unversioned aliases use a zero thinking budget. Gemini 4+ uses the lowest configured supported level or defaults to low. Tests cover Google and Vertex model IDs, empty and generated variants, and selection of the lowest configured level.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: sahrizvi

Merge Risk: ⚪ Minimal · up to 3d7f6

Gemini 4+ small calls use a thinking level rather than the rejected zero budget. The inspected Google and Vertex paths preserve that setting, and no merge-blocking risk is evident.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: using thinking levels for Gemini 4 small calls.
Description check Passed The description includes the issue, change type, root cause, implementation details, impact, verification results, screenshots status, and completed checklist. It is complete and aligned with the temp…
Linked Issues check Passed Issue #1533 requires generation-specific thinking controls for Google and Vertex small calls. ProviderTransform.smallOptions keeps thinkingBudget: 0 for Gemini 2.x and unversioned aliases, keeps `…
Out of Scope Changes check Passed The change modifies ProviderTransform.smallOptions and its focused regression tests. The implementation addresses issue #1533 and leaves non-Google providers unchanged. No unrelated product behavior…
Full details: Description check

Explanation

The description includes the issue, change type, root cause, implementation details, impact, verification results, screenshots status, and completed checklist. It is complete and aligned with the template.

Full details: Linked Issues check

Explanation

Issue #1533 requires generation-specific thinking controls for Google and Vertex small calls. ProviderTransform.smallOptions keeps thinkingBudget: 0 for Gemini 2.x and unversioned aliases, keeps thinkingLevel: "minimal" for Gemini 3, and selects the lowest configured level or "low" for Gemini 4+. The change applies only to the affected Google reasoning path. Tests cover both providers, the required generations, aliases, and configured variants.

Full details: Out of Scope Changes check

Explanation

The change modifies ProviderTransform.smallOptions and its focused regression tests. The implementation addresses issue #1533 and leaves non-Google providers unchanged. No unrelated product behavior is identified.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the Gemini flow,
With tiny thoughts set just so,
Two gets a budget, three gets minimal,
Four picks a level low and optimal,
Then hops away through fields of snow.

Comment @coderabbitai help to get the list of available commands.

@anandgupta42

Copy link
Copy Markdown
Contributor Author

@codex review

@kilo-code-bot

kilo-code-bot Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/opencode/src/provider/transform.ts
  • packages/opencode/test/provider/transform.test.ts
Previous Review Summaries (2 snapshots, latest commit 82775cc)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 82775cc)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/opencode/src/provider/transform.ts
  • packages/opencode/test/provider/transform.test.ts

Previous review (commit 380beb3)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/opencode/src/provider/transform.ts
  • packages/opencode/test/provider/transform.test.ts

Reviewed by gemini-4-argon · Input: 70.5K · Output: 1.8K · Cached: 386.7K

Review guidance: REVIEW.md from base branch main

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 2 files

View guided diff | Turn on auto-fix | Re-trigger cubic

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 380beb30be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…eration

Ids such as `vertex_gemini-3pro` matched the earlier `includes("gemini-3")`
check but not the generation regex, so they fell back to `thinkingBudget: 0`.
Adds prefixed, dated-preview and unparseable id cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anandgupta42

Copy link
Copy Markdown
Contributor Author

@codex review

@cursor

cursor Bot commented Oct 17, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 2346099b-0842-440f-8bdd-2460ea39864a)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82775cc01d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/opencode/src/provider/transform.ts Outdated
Prefixed or concatenated ids such as `vertex_gemini-4argon` did not match the
anchored pattern, so they fell back to `thinkingBudget: 0` and the 400. One
unanchored `gemini-(\d+)` parse now covers Gemini 3 and Gemini 4+ alike, which
also replaces the substring fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anandgupta42

Copy link
Copy Markdown
Contributor Author

@codex review

@cursor

cursor Bot commented Oct 17, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 14865399-697b-4f89-891b-69d64bd18af1)

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 3d7f63e549

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@anandgupta42
anandgupta42 merged commit 1ec6b15 into main Oct 17, 2026
31 checks passed
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.

Small model calls fail on Gemini 4: thinkingBudget is rejected

1 participant