Skip to content

[Feature] Add Gemini 3.0 thinking level and systemInstruction casing support#629

Merged
dingyi222666 merged 2 commits into
v1-devfrom
fix/gemini-3-non-thinking
Nov 18, 2025
Merged

[Feature] Add Gemini 3.0 thinking level and systemInstruction casing support#629
dingyi222666 merged 2 commits into
v1-devfrom
fix/gemini-3-non-thinking

Conversation

@dingyi222666
Copy link
Copy Markdown
Member

This PR adds Gemini 3.0 thinking level support and systemInstruction casing configuration.

New Features

  • Add Gemini 3.0 thinking level support (low/medium/high)
  • Add useCamelCaseSystemInstruction config option
  • Implement thinking level extraction from model names

Other Changes

  • Update default thinkingLevel to THINKING_LEVEL_UNSPECIFIED
  • Separate thinking model handling for Gemini 2.5 and 3.0
  • Fix Google Search API selection logic
  • Bump version to 1.3.6

- Add support for thinking level configuration (low/medium/high) for Gemini 3.0
- Implement thinking level extraction from model names (e.g., gemini-3.0-pro-low-thinking)
- Separate thinking model variants: Gemini 2.5 (thinking/non-thinking) vs Gemini 3.0 (level-based)
- Add filterKeys utility to remove null/undefined values from thinkingConfig
- Update safety settings to apply 'OFF' threshold for all non-Gemini-1 models
- Fix Google Search API selection logic (Gemini 1.x uses google_search_retrieval, others use google_search)
- Set thinkingBudget to undefined for Gemini 3.0 (uses level instead)
- Bump version to 1.3.5
… thinking defaults

- Add useCamelCaseSystemInstruction config option to toggle between camelCase and snake_case
- Support dynamic system instruction key selection based on configuration
- Change default thinkingLevel from 'high' to 'THINKING_LEVEL_UNSPECIFIED' for consistency
- Update Gemini 3.0 thinking level default to THINKING_LEVEL_UNSPECIFIED
- Add i18n support for new configuration option (en-US and zh-CN)
- Bump version to 1.3.6
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 18, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

该PR对Gemini适配器进行多项更新:重新分类思考模型处理(引入thinkingLevelModel),添加新的驼峰式系统指令配置选项,并更新工具处理、安全设置和生成配置逻辑以支持新的模型变体。

Changes

内聚组 / 文件 更改摘要
思考模型分类重组
packages/adapter-gemini/src/client.ts
将单一thinkingModel集合拆分为两个独立分组,引入新的thinkingLevelModel(gemini-3.0-pro),并添加分支逻辑以处理低思考变体模型。
配置选项扩展
packages/adapter-gemini/src/index.ts
在Config接口和配置schema中新增useCamelCaseSystemInstruction布尔配置选项(默认值为false),允许动态切换系统指令键名称格式。
工具与生成配置更新
packages/adapter-gemini/src/utils.ts
重构google_search工具处理逻辑、引入thinkingLevel支持、更新安全设置检查(从Gemini-2特定改为非Gemini-1通用)、完善生成配置(支持conditionalThinkingBudget和thinkingLevel)、实现动态系统指令键名。

Sequence Diagram(s)

sequenceDiagram
    participant Client as 请求客户端
    participant Adapter as Gemini适配器
    participant Config as 配置管理
    participant Utils as 工具函数
    
    Client->>Adapter: 发送请求
    Adapter->>Config: 读取useCamelCaseSystemInstruction配置
    
    alt 驼峰式模式
        Config-->>Adapter: true
        Adapter->>Utils: 使用systemInstruction键
    else snake_case模式
        Config-->>Adapter: false
        Adapter->>Utils: 使用system_instruction键
    end
    
    Utils->>Utils: 检查模型是否为thinkingLevelModel (gemini-3.0-pro)
    
    alt 匹配thinkingLevelModel
        Utils->>Utils: 应用thinkingLevel配置
        Utils->>Utils: 过滤空值生成thinkingConfig
    else 其他模型
        Utils->>Utils: 保持现有thinking逻辑
    end
    
    Utils-->>Adapter: 返回配置化的生成参数
    Adapter-->>Client: 返回处理结果
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • 关键审查点
    • packages/adapter-gemini/src/utils.ts 中的多处控制流变化(google_search、safety设置、thinkingConfig组装逻辑)需要详细验证
    • 动态系统指令键生成的兼容性影响(可能影响下游调用方)
    • thinkingLevel和thinkingBudget的条件包含逻辑确保正确性
    • 模型变体匹配逻辑(client.ts中thinkingLevelModel的新分支)需确认不会干扰现有模型路由

Possibly related PRs

Poem

🐰 Gemini的思考更深邃,
新的参数齐整纠合,
thinkingLevel轻轻舞动,
驼峰蛇形随心所欲,
适配器焕新图谱璀璨!✨

✨ 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-3-non-thinking

📜 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 a4c80c2 and e7914a3.

⛔ Files ignored due to path filters (3)
  • packages/adapter-gemini/package.json is excluded by !**/*.json
  • packages/adapter-gemini/src/locales/en-US.schema.yml is excluded by !**/*.yml
  • packages/adapter-gemini/src/locales/zh-CN.schema.yml is excluded by !**/*.yml
📒 Files selected for processing (3)
  • packages/adapter-gemini/src/client.ts (2 hunks)
  • packages/adapter-gemini/src/index.ts (2 hunks)
  • packages/adapter-gemini/src/utils.ts (9 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 upgrades the Gemini adapter by integrating new features for Gemini 3.0 models, specifically introducing support for various thinking levels to offer more precise control over model behavior. It also enhances configurability by allowing users to specify the casing for system instructions, which is crucial for interoperability. Additionally, the PR refines how Google Search is utilized and adjusts safety settings based on the specific Gemini model version, ensuring better alignment with the capabilities and requirements of different model generations.

Highlights

  • Gemini 3.0 Thinking Level Support: Introduces support for 'low', 'medium', and 'high' thinking levels for Gemini 3.0 models, allowing more granular control over model reasoning and adapting model name parsing accordingly.
  • System Instruction Casing Configuration: Adds a new configuration option useCamelCaseSystemInstruction to allow users to choose between camelCase and snake_case for the systemInstruction parameter, enhancing API compatibility.
  • Refined Model Handling and Safety Settings: Separates the logic for handling thinking models between Gemini 2.5 and Gemini 3.0, updates the default thinking level for Gemini 3.0, and adjusts safety settings to set thresholds to 'OFF' for non-Gemini 1 models.
  • Google Search API Logic Update: Modifies the Google Search API integration, with Gemini 1 models now using google_search_retrieval and other models (Gemini 2.x/3.x) using google_search.
  • Version Bump: The package version has been updated from 1.3.4 to 1.3.6.
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 58f6f28 into v1-dev Nov 18, 2025
2 of 3 checks passed
@dingyi222666 dingyi222666 deleted the fix/gemini-3-non-thinking branch November 18, 2025 18:02
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 introduces support for Gemini 3.0 thinking levels and configurable casing for systemInstruction. The changes are well-structured, and the fix for the Google Search API selection logic is a good improvement. I've identified a potential bug in how the thinkingLevel is formatted for the API, a minor translation issue, and a suggestion to improve model discoverability. Overall, great work on expanding the adapter's capabilities.

Comment thread packages/adapter-gemini/src/utils.ts
Comment thread packages/adapter-gemini/src/client.ts
Comment thread packages/adapter-gemini/src/locales/zh-CN.schema.yml
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