From 5b9497128a3aedfbce861f9f70f4b30721073768 Mon Sep 17 00:00:00 2001 From: AmanKRoy Date: Mon, 21 Sep 2026 21:38:50 +0530 Subject: [PATCH] fix: pass through gpt-5.3+ and gpt-6+ model names in normalizeModel Names newer than the hardcoded gpt-5.1/5.2 families fell through to the pattern-based fallback and were rewritten to an older model, which the Codex backend rejects with HTTP 400 (e.g. gpt-5.5). Return gpt-5.3+ and gpt-6+ names unchanged (lowercased) before the fallback so new models work without a code change. Existing mappings are untouched. Co-Authored-By: Claude Sonnet 5 --- AGENTS.md | 1 + lib/request/request-transformer.ts | 5 +++++ test/request-transformer.test.ts | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 976fc46..2aafdd4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -104,6 +104,7 @@ The main entry point orchestrates a **7-step fetch flow**: - All `gpt-5.1-codex-mini*` variants → `gpt-5.1-codex-mini` - All `gpt-5.2` variants → `gpt-5.2` - All `gpt-5.1` variants → `gpt-5.1` +- **Newer models** (`gpt-5.3+`, `gpt-6+`) pass through unchanged (lowercased), so new releases work without a code change - **Legacy mappings** (GPT-5.0 being phased out): - `gpt-5-codex*` variants → `gpt-5.1-codex` - `gpt-5-codex-mini*` or `codex-mini-latest` → `gpt-5.1-codex-mini` diff --git a/lib/request/request-transformer.ts b/lib/request/request-transformer.ts index 07f9961..04d157b 100644 --- a/lib/request/request-transformer.ts +++ b/lib/request/request-transformer.ts @@ -41,6 +41,11 @@ export function normalizeModel(model: string | undefined): string { return mappedModel; } + // Newer models (gpt-5.3+, gpt-6+) pass through unchanged + if (/^gpt-(5\.([3-9]|\d{2,})|[6-9]|[1-9]\d)/i.test(modelId)) { + return modelId.toLowerCase(); + } + // Fallback: Pattern-based matching for unknown/custom model names // This preserves backwards compatibility with old verbose names // like "GPT 5 Codex Low (ChatGPT Subscription)" diff --git a/test/request-transformer.test.ts b/test/request-transformer.test.ts index b3c0404..9708c4e 100644 --- a/test/request-transformer.test.ts +++ b/test/request-transformer.test.ts @@ -25,6 +25,24 @@ describe('Request Transformer Module', () => { expect(normalizeModel('gpt-5')).toBe('gpt-5.1'); }); + it('should pass through gpt-5.3+ model names unchanged', async () => { + expect(normalizeModel('gpt-5.5')).toBe('gpt-5.5'); + expect(normalizeModel('GPT-5.5')).toBe('gpt-5.5'); + expect(normalizeModel('gpt-5.6-luna')).toBe('gpt-5.6-luna'); + }); + + it('should pass through gpt-6+ model names unchanged', async () => { + expect(normalizeModel('gpt-6-astra')).toBe('gpt-6-astra'); + expect(normalizeModel('gpt-10')).toBe('gpt-10'); + expect(normalizeModel('GPT-10-Astra')).toBe('gpt-10-astra'); + }); + + it('should keep mapping legacy names after newer-model passthrough', async () => { + expect(normalizeModel('gpt-5.2')).toBe('gpt-5.2'); + expect(normalizeModel('gpt-5.1-codex-max')).toBe('gpt-5.1-codex-max'); + expect(normalizeModel('gpt-5-codex')).toBe('gpt-5.1-codex'); + }); + it('should normalize variants containing "codex" to gpt-5.1-codex', async () => { expect(normalizeModel('openai/gpt-5-codex')).toBe('gpt-5.1-codex'); expect(normalizeModel('custom-gpt-5-codex-variant')).toBe('gpt-5.1-codex');