Skip to content

fix(google): send thinkingLevel for any model with an effort ladder - #978

Open
DevMello wants to merge 2 commits into
lidge-jun:devfrom
DevMello:fix/gemini-reasoning-effort
Open

fix(google): send thinkingLevel for any model with an effort ladder#978
DevMello wants to merge 2 commits into
lidge-jun:devfrom
DevMello:fix/gemini-reasoning-effort

Conversation

@DevMello

@DevMello DevMello commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Selecting a reasoning effort for gemini-3.1-pro-preview now actually sends generationConfig.thinkingConfig.thinkingLevel on the wire. The catalog has advertised low/medium/high for this model since the 3.6 rollout, but the adapter hardcoded thinking to gemini-3.5-flash and gemini-3.6-flash, so the picker choice was silently ignored.
  • The gate is now ladder driven: any model whose provider config advertises reasoning efforts (registry preset or user config) gets the mapped level. The old flash slice stays hardcoded so unladdered configs keep their current behavior.
  • Vertex participates only when a user explicitly configures a ladder. The seed google-vertex entry ships none, so the Vertex freeze documented in the 260722 rollout plan is preserved. Image models are excluded because thinkingConfig would suppress responseModalities.

Verification

  • bun test tests/google-hardening.test.ts tests/google-adapter.test.ts tests/google-antigravity-wire.test.ts tests/google-vertex-stream.test.ts (77 pass)
  • bun run typecheck, the lint gate, and bun run privacy:scan
  • bun test --isolate ./tests/ full suite green (7999 pass, 0 fail)
  • New tests: pro-preview ladder emits the level and clamps minimal to low, Vertex emits only with an explicit ladder, unladdered direct flash keeps its slice, image models keep responseModalities under a provider-wide ladder.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • New Features

    • Google AI models now support configured reasoning levels where available.
    • Reasoning settings automatically adapt to each model’s supported capabilities.
    • Existing image-generation support and fallback behavior remain available.
  • Documentation

    • Clarified how Google model reasoning levels are applied, including model-specific support and exclusions.
    • Documented that configured reasoning levels are sent to eligible models.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

@github-actions github-actions Bot added the bug Something isn't working label Aug 4, 2026
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 78b9f01b-f754-4854-a56f-6077dfad8263

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The Google adapter now uses configured reasoning-effort ladders for eligible Gemini and Vertex models. Tests cover effort mapping, clamping, Vertex configuration, Flash fallback, and image-model exclusions.

Changes

Google reasoning request handling

Layer / File(s) Summary
Reasoning-aware request construction
src/adapters/google.ts, docs-site/src/content/docs/reference/configuration/providers.md
The adapter sends mapped efforts through generationConfig.thinkingConfig.thinkingLevel when the model ladder allows it. Cloud Code Assist and image-capable models remain excluded.
Model-specific behavior validation
tests/google-hardening.test.ts
Tests cover Pro preview ladders, effort clamping, Vertex ladder requirements, direct Flash fallback, omitted thinking configuration, and image response modalities.

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

Sequence Diagram(s)

sequenceDiagram
  participant ModelConfig
  participant GoogleAdapter
  participant GoogleRequest
  ModelConfig->>GoogleAdapter: configured reasoning ladder
  GoogleAdapter->>GoogleAdapter: map selected reasoning effort
  GoogleAdapter->>GoogleRequest: set thinkingConfig.thinkingLevel
Loading

Possibly related PRs

Suggested reviewers: ingwannu, wibias, lidge-jun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: sending thinkingLevel for Google models with configured reasoning-effort ladders.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@Wibias
Wibias marked this pull request as draft August 5, 2026 22:58
@DevMello
DevMello marked this pull request as ready for review August 6, 2026 07:56
@lidge-jun

Copy link
Copy Markdown
Owner

I came into this review expecting to block it, and the diff changed my mind. Recording that plainly, because the initial reading was mine and it was wrong.

The concern I started with. The title reads "for any model with an effort ladder", which sounds like the gate is widened to arbitrary configured Google-adapter providers — the proxy sending a wire field nobody verified the endpoint accepts. That would be the same mistake as promoting unknown capability to supported.

What the diff actually does. thinkingEligible is narrower than the title suggests. It excludes cloud-code-assist, excludes image-capable models so the responseModalities fallback below still fires, keeps the Vertex freeze unless a ladder is explicitly configured, and retains the hardcoded gemini-3.5/3.6-flash slice so unladdered direct configs are unchanged. And the ladder source is configuredReasoningEfforts (src/reasoning-effort.ts:58-64), which returns a value only from a registry preset or an explicit user config — never a default. That is the load-bearing detail: there is no path where a model acquires a ladder implicitly.

I ran the same probe against both trees on a custom Google-adapter provider:

Config dev this PR
custom provider, user-set modelReasoningEfforts undefined {thinkingLevel:"high"}
custom provider, no ladder undefined undefined
provider-wide reasoningEfforts undefined {thinkingLevel:"high"}

So the behavior does widen, but only where the user has asserted a ladder for that model. That is an opt-in capability assertion, not a guess — and it is the same shape we treat as the legitimate remedy elsewhere in the catalog, so blocking it here would be inconsistent with our own position. tests/google-hardening.test.ts on your head: 24 pass, 0 fail, and the four new cases cover the pro-preview ladder, the Vertex opt-in, the unladdered Flash slice, and image-model exclusion. They test the boundaries, not just the happy path.

The underlying bug is real too: gemini-3.1-pro-preview ships a ladder at src/providers/registry.ts:1217 and never receives the field on dev, so a user selecting an effort for it gets nothing on the wire.

One thing I would like before merge, and it is documentation rather than code. Setting modelReasoningEfforts now has a second effect for Google-adapter providers: it changes what goes on the wire, not only what the picker offers. That consequence is not guessable from the field name, and a user who sets a ladder to populate a menu could be surprised by a 400 from an endpoint that rejects thinkingConfig. A short note in the provider configuration reference — English source is enough, translations can follow — saying that a configured ladder is treated as an assertion that the model accepts generationConfig.thinkingConfig.thinkingLevel would close it.

Also: the failing enforce-target check is not your code. It is the stale-checkout mismatch where the run cannot resolve .github/scripts/pr-quality-state.cjs; a rebase onto current dev clears it. Please do not chase that failure.

Nice, careful piece of work — particularly keeping Vertex frozen and excluding the image models rather than letting thinkingConfig quietly suppress responseModalities.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request has been marked Ready for Review.
CodeRabbit/Codex review was requested via the review-ready label. If no review appears, comment @coderabbitai review to request one.
Maintainers notified: @lidge-jun @Ingwannu @Wibias

@github-actions
github-actions Bot marked this pull request as draft August 6, 2026 10:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/reference/configuration/providers.md`:
- Line 82: Update the modelReasoningEfforts documentation to state that both
provider-wide reasoningEfforts and per-model ladders assert native reasoning
capability for eligible non-image Google models. Describe Cloud Code Assist as
emitting the selected effort through its envelope-specific reasoning path, not
as an exception that omits reasoning fields, while preserving the image-capable
model limitation and warning that unsupported custom endpoints may reject the
request.

In `@tests/google-hardening.test.ts`:
- Around line 380-392: Add a focused non-image test near the existing
image-model test that creates the Google adapter with provider-wide
reasoningEfforts ["low", "high"], builds a request with reasoning "high", and
asserts generationConfig.thinkingConfig equals { thinkingLevel: "high" }. Use
the existing createGoogleAdapter, provider, parsed, and request-building
patterns to verify the provider-wide ladder path.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9562f786-4921-4c96-ae4a-0a005a5ee09a

📥 Commits

Reviewing files that changed from the base of the PR and between bbd82e7 and 6cc8695.

📒 Files selected for processing (3)
  • docs-site/src/content/docs/reference/configuration/providers.md
  • src/adapters/google.ts
  • tests/google-hardening.test.ts

Comment thread docs-site/src/content/docs/reference/configuration/providers.md
Comment thread tests/google-hardening.test.ts
lidge-jun added a commit that referenced this pull request Aug 6, 2026
Second loop of the bug campaign, scoped to author corrected replacements for
four contributor PRs and close theirs as absorbed. Three adversarial audit
rounds refuted the premise, and the plan now records that instead of the
outcome it was written to produce.

The decisive finding: I judged "has the author responded to our review" by
`updatedAt`, which moves when WE comment and therefore can never show author
activity. Comparing last-commit time against review time gives the real
picture:

    #1092  commits 09:38:19Z  review 09:09:51Z  -> acted, in under 30 minutes
    #1068  commits 08:52:23Z  review 09:13:15Z  -> predates the review
    #1036  commits 08-05      review 09:12:51Z  -> no response yet
    #997   commits 02:51Z     review 09:16:02Z  -> no response yet

Under the wrong reading I was about to close #1092 as absorbed — taking
credit for work its author did in direct response to my own request — and to
credit #1068 with agreeing to a review it had not yet read. Neither is a
process nit; both would have been visible to the contributor.

So the plan changes shape. #1092 and #1068 become re-reviews. #1036 and #997
get a stated 72-hour response window with a mandatory head re-check before
anything is authored or closed; "has not replied within an hour" is not
abandonment, and #997's author was active at 02:51Z. This loop therefore
authors no absorbed layer at all, and says so.

#1068's re-review carries a finding neither side has: its new test asserts
all three DeepSeek ids are in `noVisionModels`, but routing merges the
registry list, which holds only the `-free` one. Reproduced with the test's
own routeModel config — Pro=false, Flash=false, Flash-free=true — so two of
three cases fail. Latent because no check currently runs that suite.

Also corrected: the layers were called dependency-ordered when they share no
files, so s3/s4 are independent heads off `origin/dev` and the
`--update-refs` cascade is reserved for genuine chains; and #978's exclusion
no longer claims it is "already correct" when it needs an author-side docs
change.

Terminal outcome is deferred, not DONE. Shrinking the criteria to match what
finished would have hidden exactly the thing worth recording.
@DevMello
DevMello force-pushed the fix/gemini-reasoning-effort branch from 6cc8695 to 7bd15d5 Compare August 6, 2026 11:01
@DevMello
DevMello marked this pull request as ready for review August 6, 2026 11:02
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@github-actions
github-actions Bot marked this pull request as draft August 6, 2026 11:03
@DevMello
DevMello marked this pull request as ready for review August 6, 2026 11:03
@github-actions
github-actions Bot marked this pull request as draft August 6, 2026 11:03
@github-actions
github-actions Bot marked this pull request as ready for review August 6, 2026 11:09
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@github-actions[bot] The PR gate reports that pull request #978 is ready for review. I will review the current head commit.

⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The core fix is valuable and the current eligibility guard is appropriately narrow, but the latest head still needs the two follow-ups identified on the rebased diff.

  1. The documentation currently describes only modelReasoningEfforts as the capability assertion. configuredReasoningEfforts() also returns provider-wide reasoningEfforts, and that path now emits generationConfig.thinkingConfig.thinkingLevel for eligible non-image Google models. Please document both ladder sources.
  2. “except Cloud Code Assist” is misleading: CCA does not emit this exact generationConfig field, but it does consume the selected effort through resolveAntigravityEffortWireModel() and its envelope-specific wire-model path. Please describe that distinction instead of implying the effort is omitted.
  3. Add the missing positive regression for a non-image Google model with provider-wide reasoningEfforts. The current provider-wide test covers only the image-model exclusion, so it would still pass if the newly widened non-image provider-wide path stopped working.

No additional runtime blocker found in the adapter logic. Keeping changes requested until the contract text and provider-wide positive case match the actual implementation, then exact-head CI can make the final merge decision.

@lidge-jun

Copy link
Copy Markdown
Owner

Thank you — this is landing as #1137 in the stacked campaign, with your src/adapters/google.ts change adopted as authored and your commits cherry-picked with your authorship intact.

Your runtime gate was already correct; what I added on top is the contract around it. The docs now state that both reasoningEfforts and modelReasoningEfforts assert capability and that CCA uses its envelope-specific path, and I added the provider-wide non-image positive case that the suite was missing — the existing coverage was image-adjacent, so a regression in the general path could have slipped through.

Verified: 129 pass / 0 fail across the affected suites; full bun run test exit 0; typecheck and privacy scan clean.

Leaving this PR open for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants