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
4 changes: 2 additions & 2 deletions packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Plugin } from "../plugin"
import { NamedError } from "@opencode-ai/util/error"
import { type LanguageModelV3 } from "@ai-sdk/provider"
import { ModelsDev } from "./models"
import { ProviderTransform } from "./transform"
import { Auth } from "../auth"
import { Env } from "../env"
import { Instance } from "../project/instance"
Expand Down Expand Up @@ -55,7 +56,6 @@ import {
} from "gitlab-ai-provider"
import { fromNodeProviderChain } from "@aws-sdk/credential-providers"
import { GoogleAuth } from "google-auth-library"
import { ProviderTransform } from "./transform"
import { Installation } from "../installation"
import { ModelID, ProviderID } from "./schema"

Expand Down Expand Up @@ -1163,7 +1163,7 @@ export namespace Provider {
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
26 changes: 26 additions & 0 deletions pr-body.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
### Issue for this PR

Closes #22253

### Type of change

- [x] Bug fix

### What does this PR do?

Fixes custom provider models failing with "maxOutputTokens must be >= 1" when limit field is not defined.

The issue was in `provider.ts` custom model parsing where models without a `limit` field fell back to 0 instead of `OUTPUT_TOKEN_MAX` (32000). Changed the fallback to use `ProviderTransform.OUTPUT_TOKEN_MAX`, consistent with built-in models.

This is a different approach from PR #22016 which fixed the same issue in the `transform.ts` `maxOutputTokens()` function. This fix addresses it at the provider config parsing level.

### How did you verify my code works?

- Analyzed the code to understand the fallback logic
- Confirmed built-in models use `OUTPUT_TOKEN_MAX` as fallback
- Changed custom model parsing to use the same fallback

### Checklist

- [x] I have tested my changes locally
- [x] I have not included unrelated changes in this PR
Loading