Conversation
When users specify models like `openrouter:google/gemini-3.1-pro-preview`, the fallback system was using OpenRouter's generic 128K default instead of Gemini's actual 1,048,576 token context window. Added pattern-matching in getEnhancedModelMapping() fallback to infer the correct context window from the underlying model vendor name: - google/gemini-* → 1,048,576 tokens - anthropic/claude-* → 200,000 tokens - openai/gpt-4o* → 128,000 tokens - openai/o[134]* → 200,000 tokens - meta-llama/llama-3* → 131,072 tokens - deepseek/* → 65,536 tokens - mistralai/* → 131,072 tokens - qwen/* → 131,072 tokens Added 3 regression tests for OpenRouter context inference. Fixes #86 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to PR #87. The previous fix handled
google:model-namebut Sasha (@dietrichson) reported he's actually usingopenrouter:google/gemini-3.1-pro-preview, which still showed 128K instead of 1M+ tokens.Root Cause
The fallback system uses
DEFAULT_CONTEXT_WINDOWS['openrouter'](128,000) for ALL unregistered OpenRouter models, regardless of the underlying model vendor. Soopenrouter:google/gemini-3.1-pro-previewgot 128K instead of Gemini's actual 1,048,576.Fix
Added pattern-matching in
getEnhancedModelMapping()fallback to infer the correct context window from the underlying model vendor in the OpenRouter model path:google/gemini-*anthropic/claude-*openai/gpt-4o*openai/o[134]*meta-llama/llama-3*deepseek/*mistralai/*qwen/*Test plan
openrouter:google/gemini-3.1-pro-preview→ 1,048,576 tokens ✅openrouter:anthropic/claude-99→ 200,000 tokens ✅openrouter:deepseek/deepseek-r2→ 65,536 tokens ✅Fixes #86
🤖 Generated with Claude Code