fix: use thinking levels for Gemini 4 small calls
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-argonwith each config.thinkingBudget: 0returned the 400 above, andthinkingLevel: "low"returned a normal response. - Unit:
test/provider/transform.test.tshas 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 typecheckis 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 3d7f63e549a9d311e7817fe74aee84b767fc5729. 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 likevertex_gemini-4argonare handled correctly along with plain, dated, and unversioned aliases. - Gemini 2.x and unversioned aliases keep
thinkingBudget: 0, Gemini 3 keepsthinkingLevel: "minimal", and Gemini 4+ uses the lowest configured supported thinking level, falling back tolow. - 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.
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.