fix: differentiate Codex CLI models from Cursor CLI models

- Fix isCursorModel to exclude Codex-specific models (gpt-5.1-codex-*, gpt-5.2-codex-*)
- These models should route to Codex provider, not Cursor provider
- Add CODEX_YOLO_FLAG constant for --dangerously-bypass-approvals-and-sandbox
- Always use YOLO flag in codex-provider for full permissions
- Simplify codex CLI args to minimal set with YOLO flag
- Update tests to reflect new behavior with YOLO flag

This fixes the bug where selecting a Codex model (e.g., gpt-5.1-codex-max)
was incorrectly spawning cursor-agent instead of codex exec.

The root cause was:
1. Cursor provider had higher priority (10) than Codex (5)
2. isCursorModel() returned true for Codex models in CURSOR_MODEL_MAP
3. Models like gpt-5.1-codex-max routed to Cursor instead of Codex

The fix:
1. isCursorModel now excludes Codex-specific model IDs
2. Codex always uses --dangerously-bypass-approvals-and-sandbox flag
This commit is contained in:
DhanushSantosh
2026-01-08 23:03:03 +05:30
parent 7e68691e92
commit 7583598a05
3 changed files with 30 additions and 26 deletions

View File

@@ -21,7 +21,7 @@ export const PROVIDER_PREFIXES = {
* Check if a model string represents a Cursor model
*
* @param model - Model string to check (e.g., "cursor-composer-1" or "composer-1")
* @returns true if the model is a Cursor model
* @returns true if the model is a Cursor model (excluding Codex-specific models)
*/
export function isCursorModel(model: string | undefined | null): boolean {
if (!model || typeof model !== 'string') return false;
@@ -31,8 +31,18 @@ export function isCursorModel(model: string | undefined | null): boolean {
return true;
}
// Check if it's a bare Cursor model ID
return model in CURSOR_MODEL_MAP;
// 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
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-')) {
return false;
}
return true;
}
return false;
}
/**