Skip to content

fix: keep Gemini thinking disabled after clamp#101832

Merged
steipete merged 3 commits into
openclaw:mainfrom
MonkeyLeeT:codex/fix-gemini-thinking-clamp
Jul 9, 2026
Merged

fix: keep Gemini thinking disabled after clamp#101832
steipete merged 3 commits into
openclaw:mainfrom
MonkeyLeeT:codex/fix-gemini-thinking-clamp

Conversation

@MonkeyLeeT

@MonkeyLeeT MonkeyLeeT commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Closes #101785

What Problem This Solves

Fixes an issue where users requesting a Google/Gemini reasoning level that the selected model clamps down to off could still get thinking enabled at the provider's high effort level.

AI-assisted: yes, created with Codex.

Why This Change Was Made

The Google shared provider now treats clampThinkingLevel() returning off as a disabled-thinking result before mapping provider efforts. The Google simple-completion wrapper also passes the clamped effective reasoning level into the final thinking-payload sanitizer, so an unsupported max/xhigh request cannot be restored to Gemini 3 HIGH after the shared builder already disabled it. The existing max to high normalization remains in place for supported non-off Google thinking requests.

User Impact

Gemini requests whose catalog/model constraints resolve reasoning to off no longer unexpectedly send high thinking settings, avoiding unwanted token overhead and provider errors on models that should have thinking disabled.

Evidence

  • Follow-up for ClawSweeper P1 was committed and pushed at d4f31fb354f.
  • git diff --check passed after the wrapper fix.
  • /Users/fallmonkey/Developer/openclaw/node_modules/.bin/oxfmt --check --threads=1 packages/ai/src/providers/google-shared.ts packages/ai/src/providers/google-shared.test.ts src/agents/google-simple-completion-stream.ts src/agents/google-simple-completion-stream.test.ts src/llm/providers/stream-wrappers/google.test.ts passed.
  • node scripts/run-vitest.mjs packages/ai/src/providers/google-shared.test.ts src/agents/google-simple-completion-stream.test.ts src/llm/providers/stream-wrappers/google.test.ts passed as a narrow local fallback after temporarily symlinking this linked worktree to the main checkout's existing node_modules: 3 test files, 28 tests, 2 Vitest shards in 5.23s. The symlink was removed after the run.
  • Non-mock runtime payload trace on head d4f31fb354f passed. This used the actual prepareGoogleSimpleCompletionModel() and streamSimple() runtime modules with the real Google simple-completion custom API wrapper, captured the final provider payload in onPayload, then threw OPENCLAW_PAYLOAD_CAPTURED_BEFORE_NETWORK to stop before any Google network request. The redacted terminal output was:
{
  "model": "gemini-3-flash-preview",
  "wrappedApi": "openclaw-google-generative-ai-simple",
  "requestedReasoning": "xhigh",
  "capturedFinalThinkingConfig": { "thinkingLevel": "MINIMAL" },
  "stoppedBeforeNetwork": true,
  "proofChecks": {
    "noHighThinkingLevel": true,
    "noThoughtsRequested": true,
    "finalPayloadUsesMinimal": true
  }
}
{
  "model": "gemini-3-flash-preview",
  "wrappedApi": "openclaw-google-generative-ai-simple",
  "requestedReasoning": "max",
  "capturedFinalThinkingConfig": { "thinkingLevel": "MINIMAL" },
  "stoppedBeforeNetwork": true,
  "proofChecks": {
    "noHighThinkingLevel": true,
    "noThoughtsRequested": true,
    "finalPayloadUsesMinimal": true
  }
}
  • The new wrapper-level regression preserves clamped-off intent in the final Gemini 3 payload for reasoning=xhigh|max runs the actual sanitizeGoogleThinkingPayload() through the Google simple-completion wrapper payload hook. For an off-only gemini-3-flash-preview, the wrapper now calls the sanitizer with thinkingLevel: "off", and the final outbound payload remains { "thinkingConfig": { "thinkingLevel": "MINIMAL" } } with no includeThoughts and no HIGH.
  • Existing shared-builder proof still applies: buildGoogleSimpleThinking() plus buildGoogleGenerateContentParams() with off-only thinkingLevelMap emits disabled simple thinking for Gemini 2.5 and Gemini 3 clamp-to-off requests without sending HIGH or includeThoughts.
  • Remote agent proof is still blocked in this environment: blacksmith is not installed on PATH for Blacksmith Testbox, and brokered AWS Crabbox reports missing coordinator/broker auth. No secrets were printed.
  • One bounded local autoreview pass was run with /Users/fallmonkey/Developer/openclaw/.agents/skills/autoreview/scripts/autoreview --mode local; it reported clean with no accepted/actionable findings.

@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 11:15 PM ET / 03:15 UTC.

Summary
The PR preserves clamped-off Gemini reasoning through Google shared thinking and simple-completion payload sanitization, with focused regression coverage.

PR surface: Source +7, Tests +86. Total +93 across 4 files.

Reproducibility: yes. Source inspection shows current main can clamp a Google xhigh/max request to off and then map it back into enabled high Gemini thinking through the shared helper or final sanitizer.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #101785
Summary: This PR is the strongest current candidate fix for the canonical Gemini clamp-to-off issue because it covers both the shared helper and final simple-completion sanitizer path.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Use current merge-head or exact-head checks before landing because the branch is behind main.

Risk before merge

  • [P1] The branch is behind main; GitHub's merge ref contains only the intended source/test changes, but landing should still use current merge-head or exact-head checks.

Maintainer options:

  1. Decide the mitigation before merge
    Land this PR, or a maintainer-owned equivalent, after exact-head checks and let the linked canonical issue close after merge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is needed; the remaining action is normal maintainer review and exact-head landing validation.

Security
Cleared: The diff only changes provider request-shaping code and tests; no workflow, dependency, lockfile, script, permission, artifact, or secret-handling surface changed.

Review details

Best possible solution:

Land this PR, or a maintainer-owned equivalent, after exact-head checks and let the linked canonical issue close after merge.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection shows current main can clamp a Google xhigh/max request to off and then map it back into enabled high Gemini thinking through the shared helper or final sanitizer.

Is this the best way to solve the issue?

Yes. The best fix is the two-surface repair in this PR: preserve clamped off in the shared helper and pass the effective clamped level into the final simple-completion sanitizer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5bdea31c9455.

Label changes

Label justifications:

  • P2: This is a bounded Google/Gemini provider request-shaping bug with focused source proof and limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Sufficient terminal proof is in the PR body: a redacted non-mock runtime payload trace on head d4f31fb captured xhigh/max final payloads with MINIMAL thinking and no HIGH or includeThoughts before network send.
  • proof: sufficient: Contributor real behavior proof is sufficient. Sufficient terminal proof is in the PR body: a redacted non-mock runtime payload trace on head d4f31fb captured xhigh/max final payloads with MINIMAL thinking and no HIGH or includeThoughts before network send.
Evidence reviewed

PR surface:

Source +7, Tests +86. Total +93 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 12 5 +7
Tests 2 90 4 +86
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 102 9 +93

What I checked:

Likely related people:

  • Gio Della-Libera: Current-main blame on the affected helper, wrapper, and sanitizer lines points to commit 41425bf, though the commit appears broad so this is a low-confidence routing signal. (role: current blamed code snapshot; confidence: low; commits: 41425bf094ec; files: packages/ai/src/providers/google-shared.ts, src/agents/google-simple-completion-stream.ts, src/plugin-sdk/provider-stream-shared.ts)
  • vincentkoc: Recent commits touched the Google shared/provider files and adjacent Google/Vertex declarations shortly before this PR. (role: recent area contributor; confidence: medium; commits: 380bc24d25ca, 1b6f3e43d1e5; files: packages/ai/src/providers/google-shared.ts, packages/ai/src/providers/google.ts, packages/ai/src/providers/google-vertex.ts)
  • steipete: Earlier history introduced and shaped the Google provider stream helper seam used by the final sanitizer path. (role: feature history contributor; confidence: medium; commits: ec86d0f64a8f; files: src/plugin-sdk/provider-stream-shared.ts, src/plugin-sdk/provider-stream.ts, src/llm/providers/stream-wrappers/google.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (6 earlier review cycles)
  • reviewed 2026-07-07T17:30:29.179Z sha 8b9ac46 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-07T17:37:08.184Z sha 8b9ac46 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-07T19:03:20.310Z sha 8b9ac46 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-08T02:40:01.152Z sha 8b9ac46 :: needs real behavior proof before merge. :: [P1] Preserve clamped-off through the final sanitizer
  • reviewed 2026-07-08T02:55:57.129Z sha d4f31fb :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-08T03:04:50.047Z sha d4f31fb :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 7, 2026
@MonkeyLeeT
MonkeyLeeT marked this pull request as ready for review July 8, 2026 02:27

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b9ac46820

ℹ️ 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 on lines +560 to +561
if (clampedReasoning === "off") {
return { enabled: false };

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.

P1 Badge Preserve clamped-off before payload sanitization

When this path is used via the Google simple-completion adapter, this disabled thinking object is only an intermediate payload: src/agents/google-simple-completion-stream.ts:52 later calls sanitizeGoogleThinkingPayload with the original options.reasoning (max/xhigh), and src/plugin-sdk/provider-stream-shared.ts:951 maps Gemini 3 requests back to HIGH. That means the reported case where max/xhigh clamps to off still sends high thinking in the final provider request; the fix needs to pass the clamped/off intent into the sanitizer or make the sanitizer preserve an already-disabled config.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 8, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S and removed size: XS labels Jul 8, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 8, 2026
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Maintainer regression fixup complete; this is land-ready.

No known proof gaps. CHANGELOG.md remains release-owned.

@steipete
steipete merged commit f984209 into openclaw:main Jul 9, 2026
99 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
* fix: keep Gemini thinking disabled after clamp

* fix: preserve clamped Gemini thinking in wrapper

* test(ai): cover generic Gemini clamp to off

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gemini thinking is incorrectly enabled at HIGH level when clamped to off

2 participants