Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/services/api/codexShim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ export async function performCodexRequest(options: {
content: [{ type: 'input_text', text: '' }],
},
],
store: false,
stream: true,

@Gustavo-Falci Gustavo-Falci Apr 14, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the thorough review, @kevincodex1 @Vasanthdev2004 ! I've just pushed a new commit addressing all your points:

Blocker resolved: Added the google/gemini-3-flash-preview and google/gemini-3.1-pro-preview entries to both OPENAI_CONTEXT_WINDOWS and OPENAI_MAX_OUTPUT_TOKENS. OpenRouter users will now correctly get the 2M context window instead of the 128k fallback.

Test coverage added (Nit): Added explicit assertions in context.test.ts for both the native and google/ prefixed variants to prevent future regressions.

PR Description updated (Nit): Updated the summary to explicitly mention the codexShim.ts cleanup, along with the new prefixes and tests.

Everything should be green and good to go. Let me know if you need anything else!

}
Comment on lines 502 to 506

Expand Down
1 change: 0 additions & 1 deletion src/services/api/openaiShim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,6 @@ class OpenAIShimMessages {
model: request.resolvedModel,
messages: openaiMessages,
stream: params.stream ?? false,
store: false,
}
// Convert max_tokens to max_completion_tokens for OpenAI API compatibility.
// Azure OpenAI requires max_completion_tokens and does not accept max_tokens.
Expand Down
28 changes: 28 additions & 0 deletions src/utils/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,31 @@ test('MiniMax-M2.5 and M2.1 use explicit provider-specific context and output ca
upperLimit: 131_072,
})
})

test('gemini 3.x models use explicit provider-specific context and output caps', () => {
process.env.CLAUDE_CODE_USE_OPENAI = '1'
delete process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS

// gemini-3.1-pro-preview
expect(getContextWindowForModel('gemini-3.1-pro-preview')).toBe(2_000_000)
expect(getModelMaxOutputTokens('gemini-3.1-pro-preview')).toEqual({
default: 65_536,
upperLimit: 65_536,
})
expect(getMaxOutputTokensForModel('gemini-3.1-pro-preview')).toBe(65_536)

// gemini-3-flash-preview
expect(getContextWindowForModel('gemini-3-flash-preview')).toBe(2_000_000)
expect(getModelMaxOutputTokens('gemini-3-flash-preview')).toEqual({
default: 65_536,
upperLimit: 65_536,
})

// google/ prefixed versions
expect(getContextWindowForModel('google/gemini-3.1-pro-preview')).toBe(2_000_000)
expect(getContextWindowForModel('google/gemini-3-flash-preview')).toBe(2_000_000)
expect(getModelMaxOutputTokens('google/gemini-3.1-pro-preview')).toEqual({
Comment on lines +143 to +153
default: 65_536,
upperLimit: 65_536,
})
})
16 changes: 12 additions & 4 deletions src/utils/model/openaiContextWindows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,17 @@ const OPENAI_CONTEXT_WINDOWS: Record<string, number> = {
'minimax-m2.1-highspeed': 204_800,

// Google (via OpenRouter)
'google/gemini-2.0-flash':1_048_576,
'google/gemini-2.5-pro': 1_048_576,
'google/gemini-2.0-flash': 1_048_576,
'google/gemini-2.5-pro': 1_048_576,
'google/gemini-3-flash-preview': 2_000_000,
'google/gemini-3.1-pro-preview': 2_000_000,

// Google (native via CLAUDE_CODE_USE_GEMINI)
'gemini-2.0-flash': 1_048_576,
'gemini-2.5-pro': 1_048_576,
'gemini-2.5-flash': 1_048_576,
'gemini-3-flash-preview': 2_000_000,
'gemini-3.1-pro-preview': 2_000_000,
Comment on lines 128 to +132
Comment on lines +131 to +132

// Ollama local models
// Llama 3.1+ models support 128k context natively (Meta official specs).
Expand Down Expand Up @@ -248,13 +252,17 @@ const OPENAI_MAX_OUTPUT_TOKENS: Record<string, number> = {
'minimax-m2.1-highspeed': 131_072,

// Google (via OpenRouter)
'google/gemini-2.0-flash': 8_192,
'google/gemini-2.5-pro': 65_536,
'google/gemini-2.0-flash': 8_192,
'google/gemini-2.5-pro': 65_536,
'google/gemini-3-flash-preview': 65_536,
'google/gemini-3.1-pro-preview': 65_536,

// Google (native via CLAUDE_CODE_USE_GEMINI)
'gemini-2.0-flash': 8_192,
'gemini-2.5-pro': 65_536,
'gemini-2.5-flash': 65_536,
'gemini-3-flash-preview': 65_536,
'gemini-3.1-pro-preview': 65_536,
Comment on lines 261 to +265

// Ollama local models (conservative safe defaults)
'llama3.3:70b': 4_096,
Expand Down
Loading