Skip to content

Commit 3cac1b1

Browse files
committed
refactor: simplify resolveDefaultModel — always honor user config
As reviewers noted, the two conditions were logically redundant. Simplified to: if user specified a model, always return it. This makes the intent crystal clear.
1 parent add731c commit 3cac1b1

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

packages/opencode/src/acp/resolve-model.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@ import { ModelID, ProviderID } from "../provider/schema"
33
/**
44
* Pure resolution logic for choosing the default model.
55
* Separated for testability — no SDK calls, no side effects.
6+
*
7+
* If the user specified a model in config.json, always honor it —
8+
* regardless of whether the provider/model is currently loaded.
9+
* This prevents falling through to Provider.sort() which may pick a paid model.
610
*/
711
export function resolveDefaultModel(
812
specified: { providerID: ProviderID; modelID: ModelID } | undefined,
913
providers: Array<{ id: string; models: Record<string, unknown> }>,
1014
): { providerID: ProviderID; modelID: ModelID } | undefined {
11-
if (specified && providers.length) {
12-
const provider = providers.find((p) => p.id === specified.providerID)
13-
if (provider && provider.models[specified.modelID]) return specified
14-
// Provider not yet loaded or model not found — still honor the user's explicit choice
15-
// rather than falling through to Provider.sort() which may pick a paid model
16-
if (!provider || !provider.models[specified.modelID]) return specified
17-
}
18-
19-
if (specified && !providers.length) return specified
20-
21-
return undefined // let caller handle fallback
15+
if (specified) return specified
16+
return undefined
2217
}

0 commit comments

Comments
 (0)