Skip to content

Allow setting a custom max context window for Google Gemini API provider (and/or universal max context window)ย #3717

@anojndr

Description

@anojndr

What problem does this proposed feature solve?

Currently, users cannot change the max context window for the Google Gemini API provider in Roo Codeโ€”it is fixed at 1 million tokens. This is problematic for users on the Gemini free tier, where the tokens-per-minute (TPM) limit is 250k. As a result, it's easy to hit provider-side limits and get errors, especially when Roo tries to use the full 1M context window.

Additionally, Roo Code's "Intelligently condense the context window" feature is based on the max context window setting. If users could set a lower max context window (e.g., 250k), the condensation/summarization would trigger at the right time for their actual usage limits, making the feature much more useful and preventing API errors.

Describe the proposed solution in detail

  • Add an option in Roo Code settings to set a custom max context window for the Google Gemini API provider, similar to how it works for OpenAI-compatible providers.
    • This could be a per-provider setting, or (even better) a universal/global max context window setting that applies to all providers unless overridden.
  • When set, Roo Code should respect this limit for all context management, including:
    • How much context is sent in each request to Gemini
    • When to trigger "Intelligently condense the context window" (so it summarizes before hitting the user-defined limit, not the hardcoded 1M)
    • Any UI warnings or token usage displays should reflect the user-set limit
  • Ideally, this setting should be easy to find and adjust, with a sensible default (e.g., 1M for Gemini, but user-overridable).

Technical considerations or implementation details (optional)

No response

Describe alternatives considered (if any)

  • The only current workaround is to manually keep conversations short or start new threads, which is disruptive and doesn't allow users to take full advantage of Roo Code's context management features.
  • Another alternative is to only allow this for OpenAI-compatible providers, but this leaves Gemini users at a disadvantage.
  • A universal/global max context window setting would be a good alternative, as it would help users who switch between providers or use multiple models.

Additional Context & Mockups

  • This feature would especially benefit users on the Gemini free tier (250k TPM), but also anyone who wants more control over context size for cost or performance reasons.
  • It would make the "Intelligently condense the context window" feature much more effective, since condensation would happen at the right time for the user's actual limits.

Proposal Checklist

  • I have searched existing Issues and Discussions to ensure this proposal is not a duplicate.
  • This proposal is for a specific, actionable change intended for implementation (not a general idea).
  • I understand that this proposal requires review and approval before any development work begins.

Are you interested in implementing this feature if approved?

  • Yes, I would like to contribute to implementing this feature.

Metadata

Metadata

Assignees

Labels

Issue - In ProgressSomeone is actively working on this. Should link to a PR soon.enhancementNew feature or requestfeature requestFeature request, not a bug

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions