Skip to content

KG-561 Add Gemini 3 Pro Preview#1236

Merged
EugeneTheDev merged 6 commits intoJetBrains:developfrom
mltheuser:mltheuser/kg-561
Dec 10, 2025
Merged

KG-561 Add Gemini 3 Pro Preview#1236
EugeneTheDev merged 6 commits intoJetBrains:developfrom
mltheuser:mltheuser/kg-561

Conversation

@mltheuser
Copy link
Copy Markdown
Contributor

@mltheuser mltheuser commented Dec 7, 2025

Motivation and Context

This PR adds support for Google's latest model, Gemini 3 Pro Preview (gemini-3-pro-preview).

While integrating this model, significant changes were required in how "Thinking" (Reasoning) is configured compared to previous versions (Gemini 2.5):

  • Thinking Configuration: Gemini 3 abandons the token-based limit (thinkingBudget) in favor of abstract levels (thinkingLevel). Currently, LOW and HIGH are supported.
  • Validation Logic: The GoogleThinkingConfig has been updated to support these levels. An init block was added to enforce mutual exclusion: users cannot configure both a thinkingBudget (legacy/Gemini 2) and a thinkingLevel (Gemini 3) simultaneously.
  • Conversation Consistency: Gemini 3 is stricter regarding conversation history; it will fail if thought signatures are not reproduced correctly in subsequent requests.

To verify these changes:

  • Unit Tests: Added tests to ThinkingConfigTest to verify the JSON serialization of the new thinkingLevel and to ensure the mutual exclusion validation works as expected.
  • Integration Tests: The new model was added to reasoningCapableModels. Crucially, this runs it against integration_testReasoningMultiStep. This validates that multi-turn conversations maintain the correct thought signatures/context, preventing the API failures specific to Gemini 3 when history is mishandled.

Breaking Changes

No breaking changes. The new configuration parameters are optional and specifically targeted at the new model. Existing configurations for Gemini 2 or other providers remain unaffected.


Type of the changes

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tests improvement
  • Refactoring

Checklist

  • The pull request has a description of the proposed change
  • I read the Contributing Guidelines before opening the pull request
  • The pull request uses develop as the base branch
  • Tests for the changes have been added
  • All new and existing tests passed
Additional steps for pull requests adding a new feature
  • An issue describing the proposed change exists
  • The pull request includes a link to the issue
  • The change was discussed and approved in the issue
  • Docs have been added / updated

@mltheuser mltheuser changed the title Mltheuser/kg 561 KG-561 Let's add Gemini 3 Pro Preview Dec 7, 2025
@aozherelyeva aozherelyeva requested review from EugeneTheDev, Rizzen, antoniibelyshev and devcrocod and removed request for Rizzen December 8, 2025 10:19
Copy link
Copy Markdown
Contributor

@aozherelyeva aozherelyeva left a comment

Choose a reason for hiding this comment

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

Thank you! Here are some comments regarding the testing part.

maxTokens = 256
)
is LLMProvider.Google -> {
val thinkingConfig = if (model.id.contains("gemini-3")) {
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.

It's better to use the variable storing model ID: if (model.id == GoogleModels.Gemini3_Pro_Preview.id)

fun googleModels(): Stream<LLModel> {
return Stream.of(
GoogleModels.Gemini3_Pro_Preview,
GoogleModels.Gemini2_5Pro,
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.

Let's not add Gemini 3 to the googleModels until it's a preview? We can add it a bit later when it's more stable :)

return Stream.of(
OpenAIModels.Chat.GPT5_1,
AnthropicModels.Haiku_4_5,
GoogleModels.Gemini2_5Pro,
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.

Could you please remove GoogleModels.Gemini2_5Pro? I'd suggest having one model from each family to avoid too much time on high-level tests.

@mltheuser
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback! No problem, only concern I have is that by removing gemini-2.5 from the reasoningCapableModels you might miss it if someone breaks the old thinkingBudget setting, but probably an acceptable amount of risk. The change also means we no longer have to check the gemini model id in createReasoningParams.

@aozherelyeva
Copy link
Copy Markdown
Contributor

Thanks for the feedback! No problem, only concern I have is that by removing gemini-2.5 from the reasoningCapableModels you might miss it if someone breaks the old thinkingBudget setting, but probably an acceptable amount of risk. The change also means we no longer have to check the gemini model id in createReasoningParams.

That's a fair point, thank you! Let's not remove the Gemini 2.5 then 😅

Copy link
Copy Markdown
Collaborator

@EugeneTheDev EugeneTheDev left a comment

Choose a reason for hiding this comment

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

Looks good, can you rebase please?

@mltheuser
Copy link
Copy Markdown
Contributor Author

No problem. Rebased and added back gemini-2.5-pro to reasoningCapableModels for integration testing.

@mltheuser
Copy link
Copy Markdown
Contributor Author

mltheuser commented Dec 9, 2025

Man, these tests have been keeping me on my toes lately! 😅 I find myself having to squash/unsquash updates a few times on almost every PR just to rerun the pipeline until it passes. Do we have a ticket tracking this flakiness?

@EugeneTheDev
Copy link
Copy Markdown
Collaborator

Yes, sorry about that, this is a known problem, and I'm disabling these flaky tests for now until we resolve the flakiness. Hopefully after #1251 it should be stable again

@EugeneTheDev EugeneTheDev dismissed aozherelyeva’s stale review December 10, 2025 14:06

Discussed and resolved all comments

@EugeneTheDev EugeneTheDev changed the title KG-561 Let's add Gemini 3 Pro Preview KG-561 Add Gemini 3 Pro Preview Dec 10, 2025
@EugeneTheDev EugeneTheDev merged commit 3a14ae7 into JetBrains:develop Dec 10, 2025
10 checks passed
vova-jb pushed a commit that referenced this pull request Jan 27, 2026
## Motivation and Context
This PR adds support for Google's latest model, **Gemini 3 Pro Preview**
(`gemini-3-pro-preview`).

While integrating this model, significant changes were required in how
"Thinking" (Reasoning) is configured compared to previous versions
(Gemini 2.5):
* **Thinking Configuration:** Gemini 3 abandons the token-based limit
(`thinkingBudget`) in favor of abstract levels (`thinkingLevel`).
Currently, `LOW` and `HIGH` are supported.
* **Validation Logic:** The `GoogleThinkingConfig` has been updated to
support these levels. An `init` block was added to enforce mutual
exclusion: users cannot configure both a `thinkingBudget` (legacy/Gemini
2) and a `thinkingLevel` (Gemini 3) simultaneously.
* **Conversation Consistency:** Gemini 3 is stricter regarding
conversation history; it will fail if thought signatures are not
reproduced correctly in subsequent requests.

To verify these changes:
* **Unit Tests:** Added tests to `ThinkingConfigTest` to verify the JSON
serialization of the new `thinkingLevel` and to ensure the mutual
exclusion validation works as expected.
* **Integration Tests:** The new model was added to
`reasoningCapableModels`. Crucially, this runs it against
`integration_testReasoningMultiStep`. This validates that multi-turn
conversations maintain the correct thought signatures/context,
preventing the API failures specific to Gemini 3 when history is
mishandled.

## Breaking Changes
No breaking changes. The new configuration parameters are optional and
specifically targeted at the new model. Existing configurations for
Gemini 2 or other providers remain unaffected.

---

#### Type of the changes
- [x] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [x] Tests improvement
- [ ] Refactoring

#### Checklist
- [x] The pull request has a description of the proposed change
- [x] I read the [Contributing
Guidelines](https://github.com/JetBrains/koog/blob/main/CONTRIBUTING.md)
before opening the pull request
- [x] The pull request uses **`develop`** as the base branch
- [x] Tests for the changes have been added
- [x] All new and existing tests passed

##### Additional steps for pull requests adding a new feature
- [x] An issue describing the proposed change exists
- [x] The pull request includes a link to the issue
- [x] The change was discussed and approved in the issue
- [ ] Docs have been added / updated

---------

Co-authored-by: Malte Heuser <malte.heuser@ing.com>
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.

3 participants