Skip to content

Commit 7b5a00e

Browse files
committed
fix: support OpenAI Compatible provider for reasoning models
1 parent f01bb52 commit 7b5a00e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/opencode/src/provider/provider.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,10 @@ export namespace Provider {
792792
}
793793

794794
// Reasoning models require max_completion_tokens instead of max_tokens
795-
// when using openai-compatible provider
796-
// Check if model has reasoning capability OR has reasoningEffort option
797-
const isReasoningModel =
798-
model.capabilities.reasoning || (model.options && "reasoningEffort" in model.options)
799-
if (model.api.npm === "@ai-sdk/azure" && isReasoningModel) {
795+
// when using openai-compatible or azure provider
796+
const isOpenAICompatible =
797+
model.api.npm === "@ai-sdk/openai-compatible" || model.api.npm === "@ai-sdk/azure"
798+
if (isOpenAICompatible && model.capabilities.reasoning) {
800799
if (opts.body && typeof opts.body === "string") {
801800
try {
802801
const body = JSON.parse(opts.body)
@@ -806,7 +805,11 @@ export namespace Provider {
806805
opts.body = JSON.stringify(body)
807806
}
808807
} catch (e) {
809-
// Ignore JSON parse errors
808+
log.warn("Failed to transform max_tokens parameter for reasoning model", {
809+
providerID: model.providerID,
810+
modelID: model.id,
811+
error: e,
812+
})
810813
}
811814
}
812815
}

0 commit comments

Comments
 (0)