Skip to content

🐛 fix(gemini): align thinkingLevel config resolution across the stack#13457

Merged
arvinxx merged 3 commits into
lobehub:canaryfrom
Zhouguanyang:fix/gemini-thinkingconfig-split
Apr 11, 2026
Merged

🐛 fix(gemini): align thinkingLevel config resolution across the stack#13457
arvinxx merged 3 commits into
lobehub:canaryfrom
Zhouguanyang:fix/gemini-thinkingconfig-split

Conversation

@Zhouguanyang

@Zhouguanyang Zhouguanyang commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

💻 Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • ✅ test
  • 📝 docs
  • 🔨 chore

🔗 Related Issue

fixes #12959

🔀 Description of Change

本 PR 修复 Gemini 3.x thinking 参数在 UI / Resolver / Runtime 链路上的一致性问题,避免请求携带空的 thinkingConfig: {},并保证不同模型能够稳定读取并下发正确的 thinkingLevel* 配置。

  • Google runtime:省略空 thinkingConfig
    • packages/model-runtime/src/providers/google/index.ts
      • 新增 normalizeThinkingConfig:当 includeThoughts / thinkingBudget / thinkingLevel 全部为 undefined 时返回 undefined,避免发送 thinkingConfig: {}
    • packages/model-runtime/src/providers/google/index.test.ts
      • 增加回归测试:gemini-3.1-pro-preview 未显式设置 thinking 参数时,断言最终请求 config.thinkingConfig === undefined
  • UIThinkingLevel sliders 读写正确的配置 key
    • src/features/ModelSwitchPanel/components/ControlsForm/createLevelSlider.tsx
    • src/features/ModelSwitchPanel/components/ControlsForm/ThinkingLevel2Slider.tsx
    • src/features/ModelSwitchPanel/components/ControlsForm/ThinkingLevel3Slider.tsx
    • src/features/ModelSwitchPanel/components/ControlsForm/ThinkingLevel4Slider.tsx
    • src/features/ModelSwitchPanel/components/ControlsForm/ThinkingLevel5Slider.tsx
      • ThinkingLevel2/3/4/5 sliders 分别读写 thinkingLevel2/3/4/5
  • Resolver:按模型声明的 extendParams 精确映射 thinkingLevel*
    • src/services/chat/mecha/modelParamsResolver.ts
      • 当模型声明 thinkingLevel / thinkingLevel2 / thinkingLevel3 / thinkingLevel4 / thinkingLevel5 时,只从 chatConfig 中读取对应的同名 key,并下发到 extendParams.thinkingLevel
      • 当模型支持多个 thinkingLevel* 参数时,优先使用第一个已显式配置的 key;只有在所有相关 key 都未配置时,才回落到默认值。
      • 默认值规则如下:
        • thinkingLevel / thinkingLevel2 / thinkingLevel3 -> high
        • thinkingLevel4 / thinkingLevel5 -> minimal
      • 避免跨 thinkingLevel* 复用其它 key,也避免已配置值被更前面的默认值覆盖。
  • Tests:补充 thinkingLevel* 映射与优先级覆盖
    • src/services/chat/mecha/modelParamsResolver.test.ts
      • 更新并补充测试,覆盖:
        • 同名 key 映射
        • 老数据缺省时的默认值补齐
        • 多个 thinkingLevel* 同时存在时显式值优先
        • 所有相关 key 都未配置时再使用默认值回落

🧪 How to Test

  • Tested locally
  • Added/updated tests
  • No tests needed
  • bunx vitest run --silent='passed-only' 'src/services/chat/mecha/modelParamsResolver.test.ts'
  • cd packages/model-runtime && bunx vitest run --silent='passed-only' 'src/providers/google/index.test.ts'

📸 Screenshots / Videos

image

📝 Additional Information

@vercel

vercel Bot commented Mar 31, 2026

Copy link
Copy Markdown

@Zhouguanyang is attempting to deploy a commit to the LobeHub OSS Team on Vercel.

A member of the Team first needs to authorize it.

@sourcery-ai sourcery-ai 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.

Sorry @Zhouguanyang, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@lobehubbot

Copy link
Copy Markdown
Member

@sxjeru @ONLY-yours - This PR fixes Gemini thinking config consistency across the Google provider runtime, ModelSwitchPanel UI sliders, and the model params resolver. Please coordinate on the review.

@codecov

codecov Bot commented Mar 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.78261% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.49%. Comparing base (df6d8f1) to head (b8883cf).
⚠️ Report is 160 commits behind head on canary.

Additional details and impacted files
@@            Coverage Diff            @@
##           canary   #13457     +/-   ##
=========================================
  Coverage   66.48%   66.49%             
=========================================
  Files        1972     1972             
  Lines      160184   160210     +26     
  Branches    18340    16054   -2286     
=========================================
+ Hits       106504   106527     +23     
- Misses      53560    53563      +3     
  Partials      120      120             
Flag Coverage Δ
app 58.32% <84.21%> (+<0.01%) ⬆️
database 96.66% <ø> (ø)
packages/agent-runtime 88.98% <ø> (ø)
packages/context-engine 86.51% <ø> (ø)
packages/conversation-flow 92.36% <ø> (ø)
packages/file-loaders 87.02% <ø> (ø)
packages/memory-user-memory 66.68% <ø> (ø)
packages/model-bank 99.85% <ø> (ø)
packages/model-runtime 84.67% <87.50%> (+<0.01%) ⬆️
packages/prompts 67.07% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/utils 90.41% <ø> (ø)
packages/web-crawler 88.82% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 66.66% <ø> (ø)
Services 49.46% <100.00%> (+0.18%) ⬆️
Server 66.34% <ø> (ø)
Libs 51.03% <ø> (ø)
Utils 89.08% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Zhouguanyang

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/features/ModelSwitchPanel/components/ControlsForm/ThinkingLevel4Slider.tsx Outdated
@Zhouguanyang Zhouguanyang marked this pull request as draft April 1, 2026 00:18
@Zhouguanyang

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Zhouguanyang Zhouguanyang marked this pull request as ready for review April 1, 2026 01:40

@sourcery-ai sourcery-ai 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.

Sorry @Zhouguanyang, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@Zhouguanyang Zhouguanyang requested a review from sxjeru April 1, 2026 01:42

@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: cfd2a72ed5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/services/chat/mecha/modelParamsResolver.ts Outdated
@Zhouguanyang Zhouguanyang changed the title 🐛 fix(gemini): omit empty thinkingConfig and align thinkingLevel keys 🐛 fix(gemini): align thinkingLevel config resolution across the stack Apr 1, 2026
- Google runtime: omit empty thinkingConfig to avoid sending thinkingConfig: {} upstream.\n- UI: ThinkingLevel2/3/4/5 sliders read/write only their own config key.\n- Resolver: map model extend params thinkingLevel* to matching chatConfig key (no fallback/priority logic).\n- Tests: add regression coverage for empty thinkingConfig omission.
@Zhouguanyang Zhouguanyang force-pushed the fix/gemini-thinkingconfig-split branch from 2661240 to b8883cf Compare April 1, 2026 17:03
@Zhouguanyang

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@arvinxx arvinxx merged commit 39bca4b into lobehub:canary Apr 11, 2026
20 of 21 checks passed
@lobehubbot

Copy link
Copy Markdown
Member

❤️ Great PR @Zhouguanyang ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.

@Zhouguanyang Zhouguanyang deleted the fix/gemini-thinkingconfig-split branch April 11, 2026 12:05
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.

Gemini 3.1 Pro does not display thinking process

4 participants