fix(opencode): gate reasoning summaries by provider (#30973)
This commit is contained in:
parent
f8cf8fa983
commit
cc487dd032
3 changed files with 89 additions and 1 deletions
|
|
@ -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") && !input.model.api.id.includes("gpt-5-chat")) {
|
||||||
if (!input.model.api.id.includes("gpt-5-pro")) {
|
if (!input.model.api.id.includes("gpt-5-pro")) {
|
||||||
result["reasoningEffort"] = "medium"
|
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") {
|
if (input.model.api.npm === "@ai-sdk/openai" || input.model.api.npm === "@ai-sdk/amazon-bedrock/mantle") {
|
||||||
result["include"] = INCLUDE_ENCRYPTED_REASONING
|
result["include"] = INCLUDE_ENCRYPTED_REASONING
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,13 @@ export const prepare = Effect.fn("LLMRequestPrep.prepare")(function* (input: Pre
|
||||||
providerOptions: input.provider.options,
|
providerOptions: input.provider.options,
|
||||||
})
|
})
|
||||||
const options = mergeOptions(mergeOptions(mergeOptions(base, input.model.options), input.agent.options), variant)
|
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")
|
if (isOpenaiOauth) options.instructions = system.join("\n")
|
||||||
|
|
||||||
const messages =
|
const messages =
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { describe, expect, test } from "bun:test"
|
import { describe, expect, test } from "bun:test"
|
||||||
|
import { Effect } from "effect"
|
||||||
import { ProviderTransform } from "@/provider/transform"
|
import { ProviderTransform } from "@/provider/transform"
|
||||||
|
import { LLMRequestPrep } from "@/session/llm/request"
|
||||||
import { ProviderV2 } from "@opencode-ai/core/provider"
|
import { ProviderV2 } from "@opencode-ai/core/provider"
|
||||||
import { ModelV2 } from "@opencode-ai/core/model"
|
import { ModelV2 } from "@opencode-ai/core/model"
|
||||||
|
|
||||||
|
|
@ -294,6 +296,78 @@ describe("ProviderTransform.options - gpt-5 textVerbosity", () => {
|
||||||
expect(result.textVerbosity).toBe("low")
|
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", () => {
|
test("gpt-5.1 should have textVerbosity set to low", () => {
|
||||||
const model = createGpt5Model("gpt-5.1")
|
const model = createGpt5Model("gpt-5.1")
|
||||||
const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
|
const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue