Skip to content

[Feature] Add Gemini 3 thinking levels and improve model detection#647

Merged
dingyi222666 merged 1 commit into
v1-devfrom
fix/gemini-image-resolution
Dec 4, 2025
Merged

[Feature] Add Gemini 3 thinking levels and improve model detection#647
dingyi222666 merged 1 commit into
v1-devfrom
fix/gemini-image-resolution

Conversation

@dingyi222666
Copy link
Copy Markdown
Member

This PR adds support for Gemini 3 thinking level variants and improves the model detection logic in the Gemini adapter.

New Features

  • Add support for tiny-thinking, low-thinking, and high-thinking variants for Gemini 3 Pro models
  • Tiny thinking mode uses budget 128 for resource-constrained scenarios
  • Enhanced thinking level extraction to handle all four thinking modes

Other Changes

  • Refactor model name patterns from gemini-3.0 to gemini-3 for better version matching
  • Move model type constant arrays outside the iteration loop for improved performance
  • Bump adapter-gemini version from 1.3.11 to 1.3.12

…factor model detection

Add support for tiny, low, medium, and high thinking levels for Gemini 3 models.
Refactor model name patterns from 'gemini-3.0' to 'gemini-3' for better version
matching. Move model type arrays outside the loop for improved performance.

- Add tiny-thinking, low-thinking, and high-thinking variants for gemini-3-pro
- Refactor thinking level extraction to handle tiny mode with budget 128
- Update model name patterns to use 'gemini-3' instead of 'gemini-3.0'
- Move model type constant arrays outside of the model iteration loop
- Bump adapter-gemini version from 1.3.11 to 1.3.12
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

本PR更新Gemini适配器以支持新的gemini-3模型变体,增强思维级别支持(包括tiny-thinking),将模型检测逻辑从gemini-3.0更新为gemini-3,并改进图像分辨率变体的后缀处理。

Changes

凝聚体 / 文件 变更摘要
模型变体生成
packages/adapter-gemini/src/client.ts
将模型类别常量(thinkingModel、thinkingLevelModel、imageResolutionModel)从循环内移到refreshModels顶部;更新思维模型集合从'gemini-3.0-pro'改为'gemini-3-pro';为每个思维模型添加'-high-thinking'和'-tiny-thinking'变体;保留'-2K'和'-4K'图像变体生成
配置准备与后缀处理
packages/adapter-gemini/src/utils.ts
将gemini-3.0检测改为gemini-3;更新正则表达式以支持tiny后缀;为gemini-3检测到时设置thinkingBudget为undefined;添加tiny-thinking处理逻辑(设置thinkingLevel为undefined,恢复thinkingBudget为128);实现后缀移除机制以清理检测到的思维和图像大小后缀

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 分钟

  • 关注点
    • utils.ts中的正则表达式更新和tiny-thinking处理逻辑需验证是否正确处理所有后缀组合
    • client.ts中新增的思维变体生成逻辑确保不会重复创建模型变体
    • 验证model.includes()检查的变更是否完整覆盖所有gemini-3命名变体

Possibly related PRs

  • PR #638:同样修改adapter-gemini的client和utils逻辑,用于Gemini模型变体生成(包括imageResolutionModel和-2K/-4K图像大小变体处理)
  • PR #628:修改Gemini思维模型检测和变体生成(client.ts)以及相关gemini-3思维/大小处理(utils.ts)
  • PR #629:修改相同的Gemini模型变体逻辑(client.ts)和思维级别处理(utils.ts),本PR在其基础上扩展gemini-3命名和变体(包括'-tiny-thinking')

Poem

🐰 小兔的代码颂歌

思维再升级,tiny闪闪亮,
三代Gemini模型驾云翔,
后缀自动净,变体齐生成,
图像两K四K分辨高,
适配器更新迎春芳!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/gemini-image-resolution

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 769631b and f1aaaf8.

⛔ Files ignored due to path filters (1)
  • packages/adapter-gemini/package.json is excluded by !**/*.json
📒 Files selected for processing (2)
  • packages/adapter-gemini/src/client.ts (2 hunks)
  • packages/adapter-gemini/src/utils.ts (1 hunks)

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 and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @dingyi222666, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the Gemini adapter by introducing new 'thinking level' variants for Gemini 3 Pro models, including 'tiny-thinking', 'low-thinking', and 'high-thinking'. It also refines the model detection and parsing logic to accurately handle these new modes and improves overall performance by optimizing constant array declarations.

Highlights

  • Gemini 3 Thinking Levels: Introduced support for 'tiny-thinking', 'low-thinking', and 'high-thinking' variants for Gemini 3 Pro models, expanding the available thinking modes.
  • Tiny Thinking Mode: The new 'tiny-thinking' mode is configured to use a thinking budget of 128, optimized for resource-constrained environments.
  • Model Detection Logic: Enhanced the model detection and thinking level extraction logic within the Gemini adapter to correctly process all four thinking modes, including the new 'tiny-thinking' variant.
  • Model Name Patterns: Refactored internal model name patterns from 'gemini-3.0' to 'gemini-3' for improved version matching and consistency.
  • Performance Optimization: Moved constant arrays defining model types ('thinkingModel', 'thinkingLevelModel', 'imageResolutionModel') outside of an iteration loop in 'refreshModels' for better performance.
  • Version Update: The 'adapter-gemini' package version has been bumped from '1.3.11' to '1.3.12'.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dingyi222666 dingyi222666 merged commit 0eb1d65 into v1-dev Dec 4, 2025
3 of 5 checks passed
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully adds support for different Gemini 3 thinking levels and improves the model detection logic. Moving constants out of the loop is a good performance enhancement. However, I've identified a critical bug in the new thinking level parsing logic that could cause a runtime TypeError and have provided a suggested fix. I also have a medium-severity comment regarding an inconsistency in the model variants being generated, which could affect maintainability.

Comment on lines +415 to 427
if (match && match[1]) {
model = model.replace(`-${match[1]}-thinking`, '')
}

if (match && match[1] !== 'tiny') {
thinkingLevel = match[1]
} else if (match[1] === 'tiny') {
thinkingLevel = undefined
thinkingBudget = 128
} else {
// Default to THINKING_LEVEL_UNSPECIFIED for gemini-3.0 if no level specified
// Default to THINKING_LEVEL_UNSPECIFIED for gemini-3 if no level specified
thinkingLevel = 'THINKING_LEVEL_UNSPECIFIED'
model = model.replace('-thinking', '')
}
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.

critical

This logic block can cause a runtime error. If model includes 'gemini-3' but does not have a thinking level suffix (e.g., 'gemini-3-pro'), match will be null. The condition else if (match[1] === 'tiny') on line 421 will then attempt to access a property on null, causing a TypeError.

The logic can be restructured to be safer and more concise by first checking if match is truthy and then handling the different thinking levels within that block.

Suggested change
if (match && match[1]) {
model = model.replace(`-${match[1]}-thinking`, '')
}
if (match && match[1] !== 'tiny') {
thinkingLevel = match[1]
} else if (match[1] === 'tiny') {
thinkingLevel = undefined
thinkingBudget = 128
} else {
// Default to THINKING_LEVEL_UNSPECIFIED for gemini-3.0 if no level specified
// Default to THINKING_LEVEL_UNSPECIFIED for gemini-3 if no level specified
thinkingLevel = 'THINKING_LEVEL_UNSPECIFIED'
model = model.replace('-thinking', '')
}
if (match && match[1]) {
const level = match[1];
model = model.replace(`-${level}-thinking`, '');
if (level === 'tiny') {
thinkingLevel = undefined;
thinkingBudget = 128;
} else {
thinkingLevel = level;
}
} else {
// Default to THINKING_LEVEL_UNSPECIFIED for gemini-3 if no level specified
thinkingLevel = 'THINKING_LEVEL_UNSPECIFIED';
}

Comment on lines 117 to +119
{ ...info, name: model.name + '-low-thinking' },
{ ...info, name: model.name + '-high-thinking' },
{ ...info, name: model.name + '-tiny-thinking' },
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.

medium

You've added support for high-thinking and tiny-thinking variants. However, the regex in packages/adapter-gemini/src/utils.ts (line 413) also includes medium as a valid thinking level: /-(low|medium|high|tiny)-thinking/. This means a model name like gemini-3-pro-medium-thinking would be correctly parsed, but it's not discoverable as it's not generated here.

For consistency, if medium is not a supported variant that should be explicitly listed, consider removing it from the regex in utils.ts to avoid confusion. If it is a supported variant, it should be added here.

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.

1 participant