Skip to content

Commit 46a4f6b

Browse files
rekram1-nodeBenGu3
authored andcommitted
fix(opencode): gate reasoning summaries by provider (anomalyco#30973)
1 parent f221e4e commit 46a4f6b

3 files changed

Lines changed: 89 additions & 1 deletion

File tree

packages/opencode/src/provider/transform.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,14 @@ export function options(input: {
11101110
if (input.model.api.id.includes("gpt-5") && !input.model.api.id.includes("gpt-5-chat")) {
11111111
if (!input.model.api.id.includes("gpt-5-pro")) {
11121112
result["reasoningEffort"] = "medium"
1113-
result["reasoningSummary"] = "auto"
1113+
if (
1114+
input.model.api.npm === "@ai-sdk/openai" ||
1115+
input.model.api.npm === "@ai-sdk/azure" ||
1116+
input.model.api.npm === "@ai-sdk/github-copilot" ||
1117+
input.model.api.npm === "@ai-sdk/amazon-bedrock/mantle"
1118+
) {
1119+
result["reasoningSummary"] = "auto"
1120+
}
11141121
if (input.model.api.npm === "@ai-sdk/openai" || input.model.api.npm === "@ai-sdk/amazon-bedrock/mantle") {
11151122
result["include"] = INCLUDE_ENCRYPTED_REASONING
11161123
}

packages/opencode/src/session/llm/request.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ export const prepare = Effect.fn("LLMRequestPrep.prepare")(function* (input: Pre
8989
providerOptions: input.provider.options,
9090
})
9191
const options = mergeOptions(mergeOptions(mergeOptions(base, input.model.options), input.agent.options), variant)
92+
if (
93+
input.model.api.npm === "@ai-sdk/azure" &&
94+
(input.provider.options.useCompletionUrls || input.model.options.useCompletionUrls || options.useCompletionUrls)
95+
) {
96+
delete options.reasoningSummary
97+
delete options.include
98+
}
9299
if (isOpenaiOauth) options.instructions = system.join("\n")
93100

94101
const messages =

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

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { describe, expect, test } from "bun:test"
2+
import { Effect } from "effect"
23
import { ProviderTransform } from "@/provider/transform"
4+
import { LLMRequestPrep } from "@/session/llm/request"
35
import { ProviderV2 } from "@opencode-ai/core/provider"
46
import { ModelV2 } from "@opencode-ai/core/model"
57

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

299+
test("openai-compatible gpt-5 models omit Responses-only reasoningSummary", () => {
300+
const model = {
301+
...createGpt5Model("gpt-5.4"),
302+
id: "cortecs/gpt-5.4",
303+
providerID: "cortecs",
304+
api: {
305+
id: "gpt-5.4",
306+
url: "https://api.cortecs.ai/v1",
307+
npm: "@ai-sdk/openai-compatible",
308+
},
309+
}
310+
const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
311+
expect(result.reasoningEffort).toBe("medium")
312+
expect(result.reasoningSummary).toBeUndefined()
313+
expect(result.include).toBeUndefined()
314+
})
315+
316+
test("azure chat completions omit Responses-only reasoning options after variants merge", async () => {
317+
const model = {
318+
...createGpt5Model("gpt-5.4"),
319+
id: "azure/gpt-5.4",
320+
providerID: "azure",
321+
api: {
322+
id: "gpt-5.4",
323+
url: "https://azure.com",
324+
npm: "@ai-sdk/azure",
325+
},
326+
variants: {
327+
high: {
328+
reasoningEffort: "high",
329+
reasoningSummary: "auto",
330+
include: ["reasoning.encrypted_content"],
331+
},
332+
},
333+
}
334+
const result = await Effect.runPromise(
335+
LLMRequestPrep.prepare({
336+
user: {
337+
id: "msg_user-test",
338+
sessionID,
339+
role: "user",
340+
time: { created: Date.now() },
341+
agent: "test",
342+
model: { providerID: "azure", modelID: "gpt-5.4", variant: "high" },
343+
} as any,
344+
sessionID,
345+
model,
346+
agent: {
347+
name: "test",
348+
mode: "primary",
349+
options: {},
350+
permission: [],
351+
} as any,
352+
system: [],
353+
messages: [{ role: "user", content: "Hello" }],
354+
tools: {},
355+
provider: { id: "azure", options: { useCompletionUrls: true } } as any,
356+
auth: undefined,
357+
plugin: {
358+
trigger: (_name: string, _input: unknown, output: unknown) => Effect.succeed(output),
359+
list: () => Effect.succeed([]),
360+
init: () => Effect.void,
361+
} as any,
362+
flags: { outputTokenMax: 32_000, client: "test" } as any,
363+
isWorkflow: false,
364+
}),
365+
)
366+
expect(result.params.options.reasoningEffort).toBe("high")
367+
expect(result.params.options.reasoningSummary).toBeUndefined()
368+
expect(result.params.options.include).toBeUndefined()
369+
})
370+
297371
test("gpt-5.1 should have textVerbosity set to low", () => {
298372
const model = createGpt5Model("gpt-5.1")
299373
const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })

0 commit comments

Comments
 (0)