Skip to content

Commit c960109

Browse files
committed
fix(model-resolver): use numeric-aware collation for alias/version sort
When an alias like 'opus' matches multiple version-suffixed ids, localeCompare without { numeric: true } orders '4-9' above '4-10' lexicographically, silently selecting the older model. Add the standard ECMAScript 2020 { numeric: true } collation option so double-digit minor versions sort correctly. This is a forward-looking fix — single-digit versions (the only state ever shipped) produce identical results with or without { numeric: true }, so there is zero behavioral effect on today's catalogs. Fixes #96588
1 parent 1d1c2f4 commit c960109

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/agents/sessions/model-resolver.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ function tryMatchModel(modelPattern: string, availableModels: Model[]): Model |
116116

117117
if (aliases.length > 0) {
118118
// Prefer alias - if multiple aliases, pick the one that sorts highest
119-
aliases.sort((a, b) => b.id.localeCompare(a.id));
119+
aliases.sort((a, b) => b.id.localeCompare(a.id, undefined, { numeric: true }));
120120
return aliases[0];
121121
}
122122
// No alias found, pick latest dated version
123-
datedVersions.sort((a, b) => b.id.localeCompare(a.id));
123+
datedVersions.sort((a, b) => b.id.localeCompare(a.id, undefined, { numeric: true }));
124124
return datedVersions[0];
125125
}
126126

0 commit comments

Comments
 (0)