Skip to content

Commit 4a9a23e

Browse files
committed
fix(provider): ModelsDev returns empty when disk empty and fetch disabled
1 parent 6883309 commit 4a9a23e

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

packages/core/src/models-dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ export const layer = Layer.effect(
179179
const populate = Effect.gen(function* () {
180180
const fromDisk = yield* loadFromDisk
181181
if (fromDisk) return fromDisk
182+
if (Flag.OPENCODE_DISABLE_MODELS_FETCH) return {}
182183
const snapshot = yield* loadSnapshot
183184
if (snapshot) return snapshot
184-
if (Flag.OPENCODE_DISABLE_MODELS_FETCH) return {}
185185
// Flock is cross-process: concurrent opencode CLIs can race on this cache file.
186186
const text = yield* Effect.scoped(
187187
Effect.gen(function* () {

packages/opencode/src/provider/provider.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,13 @@ export const layer = Layer.effect(
15191519
(v) => omit(v, ["disabled"]),
15201520
)
15211521
}
1522+
1523+
const configLimit = configProvider?.models?.[modelID]?.limit
1524+
if (configLimit) {
1525+
if (configLimit.context) model.limit.context = configLimit.context
1526+
if (configLimit.input) model.limit.input = configLimit.input
1527+
if (configLimit.output) model.limit.output = configLimit.output
1528+
}
15221529
}
15231530

15241531
if (Object.keys(provider.models).length === 0) {

packages/opencode/test/provider/provider.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,31 @@ it.instance(
10921092
},
10931093
)
10941094

1095+
it.instance(
1096+
"config provider model limit overrides individual fields",
1097+
Effect.gen(function* () {
1098+
const providers = yield* list
1099+
const model = providers[ProviderID.make("limit-override")].models[ModelID.make("model")]
1100+
expect(model.limit.context).toBe(100000)
1101+
expect(model.limit.input).toBe(80000)
1102+
expect(model.limit.output).toBe(16000)
1103+
}),
1104+
{
1105+
config: {
1106+
provider: {
1107+
"limit-override": {
1108+
name: "Limit Override Provider",
1109+
npm: "@ai-sdk/openai-compatible",
1110+
env: [],
1111+
models: { model: { name: "Model", tool_call: true, limit: { context: 100000, input: 80000, output: 16000 } } },
1112+
options: { apiKey: "test" },
1113+
},
1114+
},
1115+
},
1116+
},
1117+
)
1118+
1119+
10951120
it.instance(
10961121
"provider options are deeply merged",
10971122
Effect.gen(function* () {

0 commit comments

Comments
 (0)