Skip to content
Closed
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 packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ const layer: Layer.Layer<
limit: {
context: model.limit?.context ?? existingModel?.limit?.context ?? 0,
input: model.limit?.input ?? existingModel?.limit?.input,
output: model.limit?.output ?? existingModel?.limit?.output ?? 0,
output: model.limit?.output ?? existingModel?.limit?.output ?? ProviderTransform.OUTPUT_TOKEN_MAX,
},
headers: mergeDeep(existingModel?.headers ?? {}, model.headers ?? {}),
family: model.family ?? existingModel?.family ?? "",
Expand Down
38 changes: 37 additions & 1 deletion packages/opencode/test/provider/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Instance } from "../../src/project/instance"
import { Plugin } from "../../src/plugin/index"
import { ModelsDev } from "../../src/provider"
import { Provider } from "../../src/provider"
import { OUTPUT_TOKEN_MAX } from "../../src/provider/transform"
import { ProviderID, ModelID } from "../../src/provider/schema"
import { Filesystem } from "../../src/util"
import { Env } from "../../src/env"
Expand Down Expand Up @@ -1745,7 +1746,7 @@ test("model limit defaults to zero when not specified", async () => {
const providers = await list()
const model = providers[ProviderID.make("no-limit")].models["model"]
expect(model.limit.context).toBe(0)
expect(model.limit.output).toBe(0)
expect(model.limit.output).toBe(OUTPUT_TOKEN_MAX)
},
})
})
Expand Down Expand Up @@ -2640,3 +2641,38 @@ test("opencode loader keeps paid models when auth exists", async () => {
}
}
})

test("custom model without output limit falls back to OUTPUT_TOKEN_MAX", async () => {
await using tmp = await tmpdir({
init: async (dir) => {
await Bun.write(
path.join(dir, "opencode.json"),
JSON.stringify({
$schema: "https://opencode.ai/config.json",
provider: {
"custom-provider": {
name: "Custom Provider",
npm: "@ai-sdk/openai-compatible",
env: [],
models: {
"custom-model": {
name: "Custom Model",
tool_call: true,
},
},
options: { apiKey: "test" },
},
},
}),
)
},
})
await Instance.provide({
directory: tmp.path,
fn: async () => {
const providers = await list()
const model = providers[ProviderID.make("custom-provider")].models["custom-model"]
expect(model.limit.output).toBe(OUTPUT_TOKEN_MAX)
},
})
})
Loading