Skip to content
Merged
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
9 changes: 8 additions & 1 deletion packages/opencode/src/provider/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,14 @@ export function options(input: {
if (input.model.api.id.includes("gpt-5") && !input.model.api.id.includes("gpt-5-chat")) {
if (!input.model.api.id.includes("gpt-5-pro")) {
result["reasoningEffort"] = "medium"
result["reasoningSummary"] = "auto"
if (
input.model.api.npm === "@ai-sdk/openai" ||
input.model.api.npm === "@ai-sdk/azure" ||
input.model.api.npm === "@ai-sdk/github-copilot" ||
input.model.api.npm === "@ai-sdk/amazon-bedrock/mantle"
) {
result["reasoningSummary"] = "auto"
}
if (input.model.api.npm === "@ai-sdk/openai" || input.model.api.npm === "@ai-sdk/amazon-bedrock/mantle") {
result["include"] = INCLUDE_ENCRYPTED_REASONING
}
Expand Down
7 changes: 7 additions & 0 deletions packages/opencode/src/session/llm/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ export const prepare = Effect.fn("LLMRequestPrep.prepare")(function* (input: Pre
providerOptions: input.provider.options,
})
const options = mergeOptions(mergeOptions(mergeOptions(base, input.model.options), input.agent.options), variant)
if (
input.model.api.npm === "@ai-sdk/azure" &&
(input.provider.options.useCompletionUrls || input.model.options.useCompletionUrls || options.useCompletionUrls)
) {
delete options.reasoningSummary
delete options.include
}
if (isOpenaiOauth) options.instructions = system.join("\n")

const messages =
Expand Down
74 changes: 74 additions & 0 deletions packages/opencode/test/provider/transform.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { describe, expect, test } from "bun:test"
import { Effect } from "effect"
import { ProviderTransform } from "@/provider/transform"
import { LLMRequestPrep } from "@/session/llm/request"
import { ProviderV2 } from "@opencode-ai/core/provider"
import { ModelV2 } from "@opencode-ai/core/model"

Expand Down Expand Up @@ -294,6 +296,78 @@ describe("ProviderTransform.options - gpt-5 textVerbosity", () => {
expect(result.textVerbosity).toBe("low")
})

test("openai-compatible gpt-5 models omit Responses-only reasoningSummary", () => {
const model = {
...createGpt5Model("gpt-5.4"),
id: "cortecs/gpt-5.4",
providerID: "cortecs",
api: {
id: "gpt-5.4",
url: "https://api.cortecs.ai/v1",
npm: "@ai-sdk/openai-compatible",
},
}
const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
expect(result.reasoningEffort).toBe("medium")
expect(result.reasoningSummary).toBeUndefined()
expect(result.include).toBeUndefined()
})

test("azure chat completions omit Responses-only reasoning options after variants merge", async () => {
const model = {
...createGpt5Model("gpt-5.4"),
id: "azure/gpt-5.4",
providerID: "azure",
api: {
id: "gpt-5.4",
url: "https://azure.com",
npm: "@ai-sdk/azure",
},
variants: {
high: {
reasoningEffort: "high",
reasoningSummary: "auto",
include: ["reasoning.encrypted_content"],
},
},
}
const result = await Effect.runPromise(
LLMRequestPrep.prepare({
user: {
id: "msg_user-test",
sessionID,
role: "user",
time: { created: Date.now() },
agent: "test",
model: { providerID: "azure", modelID: "gpt-5.4", variant: "high" },
} as any,
sessionID,
model,
agent: {
name: "test",
mode: "primary",
options: {},
permission: [],
} as any,
system: [],
messages: [{ role: "user", content: "Hello" }],
tools: {},
provider: { id: "azure", options: { useCompletionUrls: true } } as any,
auth: undefined,
plugin: {
trigger: (_name: string, _input: unknown, output: unknown) => Effect.succeed(output),
list: () => Effect.succeed([]),
init: () => Effect.void,
} as any,
flags: { outputTokenMax: 32_000, client: "test" } as any,
isWorkflow: false,
}),
)
expect(result.params.options.reasoningEffort).toBe("high")
expect(result.params.options.reasoningSummary).toBeUndefined()
expect(result.params.options.include).toBeUndefined()
})

test("gpt-5.1 should have textVerbosity set to low", () => {
const model = createGpt5Model("gpt-5.1")
const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
Expand Down
Loading