Repository navigation
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
There was a problem hiding this comment.
This fixes the reported case, but picks the wrong model on providers without prices, and it breaks the existing Model.small tests.
I checked it with a small test against Model.small, run on the base and on this PR:
- Like the issue (opencode-go): with
gpt-6-luna($0.10), a free model with no family and a pricier model, the base picksgpt-6-lunaand this PR picks the free model, so the issue is fixed. - Provider without prices (local, subscription or custom): with a
claude-haikumodel and a newerclaude-opusone, the base picks the haiku model and this PR picks the opus one. Every model without a price counts as "free", so the newest one wins, which is often the largest. Title requests could then run on big or slow models, or use up per-request quotas.
Tests:
- In
packages/core,bun test test/catalog.test.ts -t "small model"passes on the base and fails 2/2 here: one expectsnewer-lunaand getsnewer-flash, the other expectsundefinedand now gets a model. test/model.test.tspasses, but it doesn't testModel.small.- Typecheck is clean.
The public API is unchanged.
The main concern is that the size-based preference is gone (inline comment). A safer fix would keep the family list and put the provider's free models ahead of it. The two existing tests need updating to match whatever behaviour is intended. The added model.enabled check has no effect (inline comment).
| const models = value.available.filter( | ||
| (model) => | ||
| model.providerID === providerID && | ||
| model.enabled && |
There was a problem hiding this comment.
This check has no effect: value.available already contains only enabled models (all.filter((model) => model.enabled) above), so disabled models were already excluded. It can be removed, along with the part of the new comment about disabled models.
Price alone doesn't tell us whether a model is small. On providers without prices (local, subscription or custom), every model counts as "free", so this returns the newest one, often the largest (in my test it picked claude-opus over claude-haiku). It also means small always returns something: the old "no small family matched, use the session's model" fallback in SessionContext.selectTitle no longer happens. Could you keep the family preference and only add a cheaper free choice ahead of it? For example, prefer free models with a price listed on providers that also have paid models, then fall back to the family list. Note that only cost[0].input is compared here, so output prices and other price tiers are ignored. The two small model tests in test/catalog.test.ts now fail and need updating to match the intended behaviour.
39cc970 to
7f83adc
Compare
7f83adc to
861d419
Compare
Issue for this PR
Closes #52004
Type of change
What does this PR do?
Model.small hardcoded the gpt-luna family first, ignoring cost and the enabled flag. On opencode-go this always resolves to the metered gpt-6-luna, even when free models exist or the model is disabled by the user. The picker now filters to enabled models and prefers free (zero-cost) ones, falling back to the cheapest.
How did you verify your code works?
Ran bun run typecheck and bun test test/model.test.ts in packages/core (9/9 pass).
Screenshots / recordings
N/A (logic change)
Checklist
Added by the opencode bot (AI-generated).
Related: #52367, #56755