Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/model/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ export function parseUserSpecifiedModel(
case 'opus':
return getDefaultOpusModel() + (has1mTag ? '[1m]' : '')
case 'best':
return getBestModel()
return getBestModel() + (has1mTag ? '[1m]' : '')
default:
}
}
Expand Down
30 changes: 30 additions & 0 deletions src/utils/model/parseUserSpecifiedModel.bestTag.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { describe, expect, test } from 'bun:test'
import { parseUserSpecifiedModel } from './model.js'

// Regression: the `best` alias dropped the `[1m]` (1M-context) tag while the
// other aliases (opus/sonnet/haiku) preserved it. `best` resolves to the same
// model as `opus`, so `best[1m]` should behave exactly like `opus[1m]` and keep
// the 1M tag. Assertions are relational so they don't pin a specific model id.
describe('parseUserSpecifiedModel — best alias 1M tag', () => {
test('best[1m] preserves the [1m] tag, matching the opus alias', () => {
const best = parseUserSpecifiedModel('best')
const best1m = parseUserSpecifiedModel('best[1m]')

expect(best1m).toBe(`${best}[1m]`)
expect(best1m.endsWith('[1m]')).toBe(true)
})

test('best and best[1m] track the opus alias exactly', () => {
expect(parseUserSpecifiedModel('best')).toBe(parseUserSpecifiedModel('opus'))
expect(parseUserSpecifiedModel('best[1m]')).toBe(
parseUserSpecifiedModel('opus[1m]'),
)
})

test('the tag is case-insensitive and not duplicated', () => {
const best1m = parseUserSpecifiedModel('best[1m]')
expect(parseUserSpecifiedModel('BEST[1M]')).toBe(best1m)
// exactly one trailing [1m], no doubling
expect(best1m.match(/\[1m]/gi)?.length).toBe(1)
})
})