Skip to content

Conversation

@HahaBill
Copy link
Contributor

@HahaBill HahaBill commented Jun 19, 2025

Related GitHub Issue

Closes: #4519

Description

  • allow users to modify topP, topK, and maxOutputTokens
  • allow users to enable URL context and Grounding with Google Search

Test Procedure

Gemini parameters
(1) Go to Settings
(2) Click on the provider)
(3) Try to modify topP, topK and maxOutputTokens

Gemini Context Management
(1) Go to Settings
(2) Click on the provider)
(3) Enable use of custom context limit
(4) Set contextLimit and profile-specific thresholding to condense at particular tokens n
(5) Go back to chat and reach n
(6) If n is reached then it will condense the conversation

Gemini Tools
(1) Go to Settings
(2) Click on the provider)
(3) Enable URL context
(4) Go back to chat and try to write a prompt with having an URL in there

(1) Go to Settings
(2) Click on the provider)
(3) EnableGrounding with Google Search
(4) Go back to chat and try to write a prompt. It should search for resources online.

Unit Tests
Gemini.spec.tsx
gemini-handler.spec.ts

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • New Feature: Non-breaking change that adds functionality.
  • 💥 Breaking Change: Fix or feature that would cause existing functionality to not work as expected.
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature.
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files.
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify src or test files.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Overall UI change

Screenshot 2025-07-08 at 01 17 51

URL Context

url_context

Grounding with Google Search

Example #1
grounding_with_google_search
Example #2
Screenshot 2025-07-08 at 01 09 31

Documentation Updates

Additional Notes

contextLimit can use functionality and implementation from this PR: #4360 for users to strategically set max context window. Better naming and description will be made.

Get in Touch


Important

Adds customizable settings for Gemini provider, including topP, topK, maxOutputTokens, and context options, with corresponding UI and tests.

  • Behavior:
    • Users can modify topP, topK, maxOutputTokens, and contextLimit in provider-settings.ts.
    • Users can enable URL context and grounding with Google Search in provider-settings.ts.
  • GeminiHandler:
    • GeminiHandler in gemini.ts now slices messages based on contextLimit and configures tools for URL context and grounding.
    • Supports maxOutputTokens, topP, topK, and tools configuration.
  • Tests:
    • Added gemini-handler.spec.ts to test GeminiHandler functionalities.
    • Added Gemini.spec.tsx to test UI components for Gemini settings.
  • UI Components:
    • Updated ApiOptions.tsx and SettingsView.tsx to include new Gemini settings.
    • Gemini.tsx now supports sliders for topP, topK, maxOutputTokens, and context management options.
  • Localization:
    • Updated localization files for new Gemini settings in multiple languages.

This description was created by Ellipsis for 1497edd. You can customize this summary. It will automatically update as commits are pushed.

- with topP, topK, maxOutputTokens
- allow users to enable URL context and Grounding Research
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 19, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Draft / In Progress] in Roo Code Roadmap Jun 19, 2025
@hannesrudolph hannesrudolph added PR - Draft / In Progress and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 20, 2025
@HahaBill
Copy link
Contributor Author

This PR is finally done :)

I still need to add a demo video and motivation behind context management section for Gemini and contextLimit. However, I will still turn this on for reviews.

@HahaBill HahaBill marked this pull request as ready for review June 27, 2025 00:00
@HahaBill HahaBill requested review from cte, jr and mrubens as code owners June 27, 2025 00:00
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Jun 27, 2025
"geminiParameters": {
"topK": {
"title": "शीर्ष K",
"description": "प्रत्येक चरण के लिए विचार करने के लिए उच्चतम संभावना वाले टोकनों की संख्या को नियंत्रित करता है। उच्च मान विविधता बढ़ाते हैं, निम्न मान आउटपुट को अधिक केंद्रित और निर्धार्त बनाते हैं।"
Copy link
Contributor

Choose a reason for hiding this comment

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

Typographical error: In the 'topK' description, "निर्धार्त" should likely be "निर्धारित".

Suggested change
"description": "प्रत्येक चरण के लिए विचार करने के लिए उच्चतम संभावना वाले टोकनों की संख्या को नियंत्रित करता है। उच्च मान विविधता बढ़ाते हैं, निम्न मान आउटपुट को अधिक केंद्रित और निर्धार्त बनाते हैं।"
"description": "प्रत्येक चरण के लिए विचार करने के लिए उच्चतम संभावना वाले टोकनों की संख्या को नियंत्रित करता है। उच्च मान विविधता बढ़ाते हैं, निम्न मान आउटपुट को अधिक केंद्रित और निर्धारित बनाते हैं।"

@dosubot dosubot bot added the enhancement New feature or request label Jun 27, 2025
@HahaBill
Copy link
Contributor Author

@daniel-lxs I had a small discussion with the team and maybe we should put the "Output controls" (topP, topK and maxOutputTokens) in the new "Advanced settings" too? Only advanced users will use these parameters and it makes sense to put them in the "Advanced settings".

It may align with your goal to make it less confusing for the users and for me it actually looks clearer. Let me know what do you think about this.

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jul 18, 2025
@RooCodeInc RooCodeInc deleted a comment from roomote bot Jul 18, 2025
…rameters

- Fixed duplicate keys in 13 localization files (es, fr, hi, id, it, ja, ko, nl, pl, pt-BR, ru, tr, vi)
- Removed second occurrence of geminiSections and geminiParameters keys
- Kept first occurrence which contains more comprehensive descriptions
- All JSON files validated for syntax correctness
- Translation completeness verified with missing translations script

Resolves duplicate key issue identified in PR RooCodeInc#4895
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Jul 18, 2025
@RooCodeInc RooCodeInc deleted a comment from roomote bot Jul 18, 2025
@delve-auditor
Copy link

delve-auditor bot commented Jul 18, 2025

No security or compliance issues detected. Reviewed everything up to 847756c.

Security Overview
  • 🔎 Scanned files: 25 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@RooCodeInc RooCodeInc deleted a comment from roomote bot Jul 18, 2025
@RooCodeInc RooCodeInc deleted a comment from roomote bot Jul 18, 2025
@RooCodeInc RooCodeInc deleted a comment from roomote bot Jul 18, 2025
@RooCodeInc RooCodeInc deleted a comment from roomote bot Jul 18, 2025
@RooCodeInc RooCodeInc deleted a comment from roomote bot Jul 18, 2025
@RooCodeInc RooCodeInc deleted a comment from roomote bot Jul 18, 2025
@roomote
Copy link
Contributor

roomote bot commented Jul 18, 2025

Issue Already Resolved

The duplicate translation keys issue has already been fixed!

Summary:

  • Found commit that already resolved the duplicate and keys
  • All 13 localization files mentioned (es, fr, hi, id, it, ja, ko, nl, pl, pt-BR, ru, tr, vi) have been cleaned up
  • Verified all JSON files are syntactically valid with no duplicate keys
  • Ran missing translations script - all translations are complete ✅

Files verified:

  • All translation files pass JSON validation
  • No duplicate keys detected in any locale
  • Translation completeness confirmed across all languages

The duplicate key consolidation work is complete and the localization files are in good shape!

@mrubens
Copy link
Collaborator

mrubens commented Jul 19, 2025

Could we split up this PR and get out this part of it ASAP while we figure out the rest? I'm particularly excited about these two checkboxes, and they're fine where they are in the UI.

(A couple tiny nitpicks - I do think we should use sentence case for the labels and add a tiny bit more spacing between the label and the explanatory text below)

Screenshot 2025-07-18 at 11 48 25 PM

@mrubens
Copy link
Collaborator

mrubens commented Jul 19, 2025

As for the other discussions that I think might take a little longer and I would like to separate from the two additions above:

  1. I think TopK and TopP should go in the advanced settings with temperature if we have them at all. And btw, is there a reason to only have them for Gemini if we decide to have them? I'm not 100% convinced we need them though.
  2. It seems like the max tokens slider conflicts with the slider that we show when reasoning is enabled. And if we do think it's worthwhile, seems like it also applies to all providers / not just Gemini?

Thank you very much for your contributions and your patience in figuring out the best way to integrate them!

@HahaBill
Copy link
Contributor Author

Could we split up this PR and get out this part of it ASAP while we figure out the rest? I'm particularly excited about these two checkboxes, and they're fine where they are in the UI.

(A couple tiny nitpicks - I do think we should use sentence case for the labels and add a tiny bit more spacing between the label and the explanatory text below)

Screenshot 2025-07-18 at 11 48 25 PM

Hi, thank you for reviewing the PR :) I will do this asap and create a new PR with the requested changes.

@HahaBill
Copy link
Contributor Author

As for the other discussions that I think might take a little longer and I would like to separate from the two additions above:

  1. I think TopK and TopP should go in the advanced settings with temperature if we have them at all. And btw, is there a reason to only have them for Gemini if we decide to have them? I'm not 100% convinced we need them though.
  2. It seems like the max tokens slider conflicts with the slider that we show when reasoning is enabled. And if we do think it's worthwhile, seems like it also applies to all providers / not just Gemini?

Thank you very much for your contributions and your patience in figuring out the best way to integrate them!

Alright, got it! Let's discuss this more for sure.

Yeah, it doesn't have to be only for Gemini. I am focusing on Gemini initially because I am most familiar with it and have a DeepMind team to help provide ground-truth sources to back my proposals. This gives me more confidence that my contributions are truly beneficial to Roo Code. That said, I am certainly open to implementing features for other providers too :)

Going forward, I will try to design new features in a way so they are more abstract or implementing adapters so that other providers can adopt them too if relevant.

But back to the issue: I can implement this the same way temperature control is, and I agree with putting all of them in the advanced settings. I will reiterate with the team about the parameters.

mrubens added a commit that referenced this pull request Jul 27, 2025
…rch (#5959)

* feat: Adding more settings and control over Gemini

- with topP, topK, maxOutputTokens
- allow users to enable URL context and Grounding Research

* feat: Adding parameter titles and descriptions + translation to all languages

* feat: adding more translations

* feat: adding `contextLimit` implementation from `maxContextWindow` PR + working with profile-specific thresholding

* feat: max value for context limit to model's limit + converting description and titles to settings for translation purposes

* feat: all languages translated

* feat: changing profile-specific threshold in context management setting will also change in Gemini context management

- sync between Context Management Settting <-> Gemini Context Management with regards to thresholding

* feat: max value of maxOutputTokens is model's maxTokens + adding more tests

* feat: improve unit tests and adding `data-testid` to slider and checkbox components

* fix: small changes in geminiContextManagement descriptions + minor fix

* fix: Switching from "Gemini Context Management" to "Token Management

- better naming and correct purpose

* fix: input field showed NaN -> annoying UX

* fix: Removing redundant "tokens" after the "set context limit"'s checkbox + removing the lengthy description

* fix: Changing the translation to be consistent with the english one

* fix: more translations

* fix: translations

* fix: removing contextLimit and token management related code

- due to the decision in: #3717

* fix: removing `contextLimit` test and removing token management in translations

* fix: changing from `Advanced Features` to `Tools` to be consistent with Gemini docs/AI studio

* fix: adding `try-catch` block for `generateContentStream`

* feat: Include citations + improved type safety

* feat: adding citation for streams (generateContextStream)

* fix: set default values for `topP`, `topK` and `maxOutputTokens`

* fix: changing UI/UX according to the review/feedback from `daniel-lxs`

* fix: updating the `Gemini.spec.tsx` unit test

- testing when it is hidden
- testing when users click on the collapsible trigger and model configuration appears

* fix: more changes from the feedback/review from `daniel-lxs`

* fix: adding sources at the end of the stream to preserve

* fix: change the description for grounding with google search and url context

* fix: adding translations

* fix: removing redundant extra translations - a mistake made by the agent

* fix: remove duplicate translation keys in geminiSections and geminiParameters

- Fixed duplicate keys in 13 localization files (es, fr, hi, id, it, ja, ko, nl, pl, pt-BR, ru, tr, vi)
- Removed second occurrence of geminiSections and geminiParameters keys
- Kept first occurrence which contains more comprehensive descriptions
- All JSON files validated for syntax correctness
- Translation completeness verified with missing translations script

Resolves duplicate key issue identified in PR #4895

* fix: delete topK, topP and maxOutputTokens from Gemini

* fix: deleting topK, topP and maxOutputTokens from translations/locales

* fix: adjust spacing between labels and descriptions + sentence casing

* fix: adding maxOutputTokens back and removing unknown type

* fix: internalizing error Gemini error message

* fix: updating tests in Gemini and Vertex to adjust to the new error logging

* fix: address PR review feedback for Gemini tools feature

- Fix Hindi translation grammatical error in settings.json
- Internationalize 'Sources:' string and error messages in gemini.ts
- Add comprehensive error scenario tests to gemini-handler.spec.ts
- Remove unused currentModelId prop from Gemini component
- Update all locale files with new translation keys

---------

Co-authored-by: Roo Code <[email protected]>
Co-authored-by: Matt Rubens <[email protected]>
Co-authored-by: Daniel Riccio <[email protected]>
@daniel-lxs
Copy link
Member

Closing for now since some of these settings are already in Roo Code

@daniel-lxs daniel-lxs closed this Jul 30, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 30, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jul 30, 2025
@HahaBill
Copy link
Contributor Author

Closing for now since some of these settings are already in Roo Code

Sounds good!

utarn pushed a commit to modelharbor/ModelHarbor-Agent that referenced this pull request Aug 1, 2025
…rch (RooCodeInc#5959)

* feat: Adding more settings and control over Gemini

- with topP, topK, maxOutputTokens
- allow users to enable URL context and Grounding Research

* feat: Adding parameter titles and descriptions + translation to all languages

* feat: adding more translations

* feat: adding `contextLimit` implementation from `maxContextWindow` PR + working with profile-specific thresholding

* feat: max value for context limit to model's limit + converting description and titles to settings for translation purposes

* feat: all languages translated

* feat: changing profile-specific threshold in context management setting will also change in Gemini context management

- sync between Context Management Settting <-> Gemini Context Management with regards to thresholding

* feat: max value of maxOutputTokens is model's maxTokens + adding more tests

* feat: improve unit tests and adding `data-testid` to slider and checkbox components

* fix: small changes in geminiContextManagement descriptions + minor fix

* fix: Switching from "Gemini Context Management" to "Token Management

- better naming and correct purpose

* fix: input field showed NaN -> annoying UX

* fix: Removing redundant "tokens" after the "set context limit"'s checkbox + removing the lengthy description

* fix: Changing the translation to be consistent with the english one

* fix: more translations

* fix: translations

* fix: removing contextLimit and token management related code

- due to the decision in: RooCodeInc#3717

* fix: removing `contextLimit` test and removing token management in translations

* fix: changing from `Advanced Features` to `Tools` to be consistent with Gemini docs/AI studio

* fix: adding `try-catch` block for `generateContentStream`

* feat: Include citations + improved type safety

* feat: adding citation for streams (generateContextStream)

* fix: set default values for `topP`, `topK` and `maxOutputTokens`

* fix: changing UI/UX according to the review/feedback from `daniel-lxs`

* fix: updating the `Gemini.spec.tsx` unit test

- testing when it is hidden
- testing when users click on the collapsible trigger and model configuration appears

* fix: more changes from the feedback/review from `daniel-lxs`

* fix: adding sources at the end of the stream to preserve

* fix: change the description for grounding with google search and url context

* fix: adding translations

* fix: removing redundant extra translations - a mistake made by the agent

* fix: remove duplicate translation keys in geminiSections and geminiParameters

- Fixed duplicate keys in 13 localization files (es, fr, hi, id, it, ja, ko, nl, pl, pt-BR, ru, tr, vi)
- Removed second occurrence of geminiSections and geminiParameters keys
- Kept first occurrence which contains more comprehensive descriptions
- All JSON files validated for syntax correctness
- Translation completeness verified with missing translations script

Resolves duplicate key issue identified in PR RooCodeInc#4895

* fix: delete topK, topP and maxOutputTokens from Gemini

* fix: deleting topK, topP and maxOutputTokens from translations/locales

* fix: adjust spacing between labels and descriptions + sentence casing

* fix: adding maxOutputTokens back and removing unknown type

* fix: internalizing error Gemini error message

* fix: updating tests in Gemini and Vertex to adjust to the new error logging

* fix: address PR review feedback for Gemini tools feature

- Fix Hindi translation grammatical error in settings.json
- Internationalize 'Sources:' string and error messages in gemini.ts
- Add comprehensive error scenario tests to gemini-handler.spec.ts
- Remove unused currentModelId prop from Gemini component
- Update all locale files with new translation keys

---------

Co-authored-by: Roo Code <[email protected]>
Co-authored-by: Matt Rubens <[email protected]>
Co-authored-by: Daniel Riccio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Needs Review size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Finer-grained control of Gemini models

5 participants