fix: expand Codex model routing to cover ALL Codex models

- Update isCursorModel to exclude ALL Codex models from Cursor routing
- Check against CODEX_MODEL_CONFIG_MAP for comprehensive exclusion
- Includes: gpt-5.2-codex, gpt-5.1-codex-max, gpt-5.1-codex-mini, gpt-5.2, gpt-5.1
- Also excludes overlapping models like gpt-5.2 and gpt-5.1 that exist in both maps
- Update test to expect CodexProvider for gpt-5.2 (correct behavior)

This ensures ALL Codex CLI models route to Codex provider, not Cursor.
Previously only gpt-5.1-codex-* and gpt-5.2-codex-* were excluded.
This commit is contained in:
DhanushSantosh
2026-01-08 23:17:35 +05:30
parent 7583598a05
commit 08ccf2632a
2 changed files with 17 additions and 6 deletions

View File

@@ -129,10 +129,11 @@ describe('provider-factory.ts', () => {
});
describe('Cursor models via model ID lookup', () => {
it('should return CursorProvider for gpt-5.2 (valid Cursor model)', () => {
// gpt-5.2 is in CURSOR_MODEL_MAP
it('should return CodexProvider for gpt-5.2 (Codex model, not Cursor)', () => {
// gpt-5.2 is in both CURSOR_MODEL_MAP and CODEX_MODEL_CONFIG_MAP
// It should route to Codex since Codex models take priority
const provider = ProviderFactory.getProviderForModel('gpt-5.2');
expect(provider).toBeInstanceOf(CursorProvider);
expect(provider).toBeInstanceOf(CodexProvider);
});
it('should return CursorProvider for grok (valid Cursor model)', () => {

View File

@@ -8,7 +8,8 @@
import type { ModelProvider } from './settings.js';
import { CURSOR_MODEL_MAP, type CursorModelId } from './cursor-models.js';
import { CLAUDE_MODEL_MAP, CODEX_MODEL_MAP, type CodexModelId } from './model.js';
import { CLAUDE_MODEL_MAP, CODEX_MODEL_MAP } from './model.js';
import { CODEX_MODEL_CONFIG_MAP, type CodexModelId } from './codex-models.js';
/** Provider prefix constants */
export const PROVIDER_PREFIXES = {
@@ -32,11 +33,20 @@ export function isCursorModel(model: string | undefined | null): boolean {
}
// Check if it's a bare Cursor model ID (excluding Codex-specific models)
// Codex-specific models like gpt-5.1-codex-* should go to Codex, not Cursor
// Codex-specific models should always route to Codex provider, not Cursor
if (model in CURSOR_MODEL_MAP) {
// Exclude Codex-specific model IDs that are in Cursor's model map
// These models should be routed to Codex provider instead
if (model.startsWith('gpt-5.1-codex-') || model.startsWith('gpt-5.2-codex-')) {
// This includes all Codex model variants (standard, high, max, mini, etc.)
if (
model.startsWith('gpt-5.1-codex-') ||
model.startsWith('gpt-5.2-codex-') ||
// Also exclude bare Codex models that overlap with Cursor's OpenAI models
model === 'gpt-5.2' ||
model === 'gpt-5.1' ||
// Exclude all Codex models from CODEX_MODEL_CONFIG_MAP
model in CODEX_MODEL_CONFIG_MAP
) {
return false;
}
return true;