Skip to content

fix(openrouter): correct reserved tokens for google/gemini-2.5-pro-preview #3896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shariqriazz
Copy link

@shariqriazz shariqriazz commented May 23, 2025

Possible fix for #3817

Screenshot 2025-05-23 at 6 45 16 PM

Important

Sets maxTokens to 66000 for google/gemini-2.5-pro-preview in getOpenRouterModels and adds a test for it.

  • Behavior:
    • Sets maxTokens to 66000 for google/gemini-2.5-pro-preview in getOpenRouterModels in openrouter.ts.
  • Tests:
    • Adds test in openrouter.test.ts to verify maxTokens is set to 66000 for google/gemini-2.5-pro-preview.

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

@@ -106,7 +106,11 @@ export async function getOpenRouterModels(options?: ApiHandlerOptions): Promise<
id,
model,
modality: architecture?.modality,
maxTokens: id.startsWith("anthropic/") ? top_provider?.max_completion_tokens : 0,
maxTokens: id.startsWith("anthropic/")
Copy link

Choose a reason for hiding this comment

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

The nested ternary for maxTokens reduces clarity. Consider extracting the condition (and using a named constant for 66000) to improve maintainability.

@shariqriazz shariqriazz marked this pull request as draft May 23, 2025 13:42
@shariqriazz shariqriazz marked this pull request as ready for review May 23, 2025 13:46
maxTokens: id.startsWith("anthropic/") ? top_provider?.max_completion_tokens : 0,
maxTokens: id.startsWith("anthropic/")
? top_provider?.max_completion_tokens
: id === "google/gemini-2.5-pro-preview"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does openrouter just not include this number? Is that a bug?

Copy link
Author

Choose a reason for hiding this comment

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

let me check it thoroughly

Copy link
Author

Choose a reason for hiding this comment

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

after doing some debugging ive hit a wall, the model file we fetch from openrouter does have it as 66k but without this i see 209k and hardcoding is showing 66k correctly. am still trying to figure it out why its happening with gemini or its an issue for all models in openrouter

@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 23, 2025
@shariqriazz shariqriazz marked this pull request as draft May 25, 2025 18:35
@shariqriazz
Copy link
Author

@mrubens its an issue with flash thinking also , i will test some more models tomorrow to see if its just gemini issue or entire openrouter model list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: PR [Pre Approval Review]
Development

Successfully merging this pull request may close these issues.

2 participants