From 3fa255fefc4bcf075edb15b04d0423b126c9488e Mon Sep 17 00:00:00 2001 From: iamtoruk Date: Sun, 31 May 2026 05:37:12 -0700 Subject: [PATCH] fix(models): match model names on version boundary, not bare prefix A bare startsWith let an unlisted future minor collapse into the base entry (gpt-5.6 -> "GPT-5"), the same mis-bucketing class as #420 but for non-Claude families. Require an exact match or a key-plus-dash boundary in both getShortModelName and the Codex provider so new versions fall through to their raw id instead of a wrong name and pricing tier. --- src/models.ts | 5 ++++- src/providers/codex.ts | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/models.ts b/src/models.ts index 86fe17d..29a3889 100644 --- a/src/models.ts +++ b/src/models.ts @@ -478,7 +478,10 @@ export function getShortModelName(model: string): string { const claude = deriveClaudeShortName(canonical) if (claude) return claude for (const [key, name] of SORTED_SHORT_NAMES) { - if (canonical.startsWith(key)) return name + // Match on a version boundary, not a bare prefix: an unlisted future minor + // (e.g. gpt-5.6) must NOT collapse into the base "gpt-5" entry — it should + // fall through to its raw id rather than show a wrong name/tier. + if (canonical === key || canonical.startsWith(key + '-')) return name } return canonical } diff --git a/src/providers/codex.ts b/src/providers/codex.ts index 3e1f327..a97328d 100644 --- a/src/providers/codex.ts +++ b/src/providers/codex.ts @@ -23,6 +23,10 @@ const modelDisplayNames: Record = { 'gpt-4o': 'GPT-4o', } +// Longest-first + version-boundary match so an unlisted future minor (gpt-5.6) +// falls through to its raw id instead of collapsing into the base "GPT-5" entry. +const modelDisplayEntries = Object.entries(modelDisplayNames).sort((a, b) => b[0].length - a[0].length) + const toolNameMap: Record = { exec_command: 'Bash', read_file: 'Read', @@ -589,8 +593,8 @@ export function createCodexProvider(codexDir?: string): Provider { displayName: 'Codex', modelDisplayName(model: string): string { - for (const [key, name] of Object.entries(modelDisplayNames)) { - if (model.startsWith(key)) return name + for (const [key, name] of modelDisplayEntries) { + if (model === key || model.startsWith(key + '-')) return name } return model },