From 1a2b985777cf5e88aad9b846019291e569dcf4e2 Mon Sep 17 00:00:00 2001 From: Victor Navarro Date: Mon, 7 Sep 2026 10:49:36 +0200 Subject: [PATCH] refactor(core): remove legacy Console variant normalization (#47760) --- packages/core/src/plugin/provider/opencode.ts | 18 +--------- .../test/plugin/provider-opencode.test.ts | 34 +++++-------------- 2 files changed, 9 insertions(+), 43 deletions(-) diff --git a/packages/core/src/plugin/provider/opencode.ts b/packages/core/src/plugin/provider/opencode.ts index cbf53ba4f9b..a9f5dc99c88 100644 --- a/packages/core/src/plugin/provider/opencode.ts +++ b/packages/core/src/plugin/provider/opencode.ts @@ -163,11 +163,7 @@ export const OpencodePlugin = define ({ @@ -236,18 +232,6 @@ function fetchProviders(http: HttpClient.HttpClient, value: Credential.Value) { ) } -function variantBody(body: Readonly>, packageName: string | undefined) { - if (packageName !== Provider.aisdk("@ai-sdk/openai")) return body - const { reasoningEffort, reasoningSummary, ...native } = body - const reasoning = { - ...(typeof reasoningEffort === "string" ? { effort: reasoningEffort } : {}), - ...(typeof reasoningSummary === "string" ? { summary: reasoningSummary } : {}), - } - if (Object.keys(reasoning).length === 0) return body - // Existing Console variants stored SDK options here before V2 consumed raw bodies. - return Provider.mergeOverlay({ reasoning }, native) -} - function withoutCredentials(body: Readonly> | undefined) { return ( body && diff --git a/packages/core/test/plugin/provider-opencode.test.ts b/packages/core/test/plugin/provider-opencode.test.ts index d0a507b7867..11119a7bc1f 100644 --- a/packages/core/test/plugin/provider-opencode.test.ts +++ b/packages/core/test/plugin/provider-opencode.test.ts @@ -380,40 +380,23 @@ describe("OpencodePlugin", () => { ), ) - it.live("normalizes legacy Console OpenAI variant bodies without changing native bodies", () => + it.live("preserves native Console OpenAI variant bodies in inference requests", () => Effect.acquireUseRelease( Effect.sync(() => { const variants = [ - { - id: "legacy", - body: { reasoningEffort: "high", reasoningSummary: "auto" }, - expected: { reasoning: { effort: "high", summary: "auto" } }, - }, { id: "effort-only", - body: { reasoningEffort: "low" }, - expected: { reasoning: { effort: "low" } }, + body: { reasoning: { effort: "low" } }, }, { id: "summary-only", - body: { reasoningSummary: "detailed" }, - expected: { reasoning: { summary: "detailed" } }, + body: { reasoning: { summary: "detailed" } }, }, { id: "native", body: { reasoning: { effort: "high", summary: "auto" } }, - expected: { reasoning: { effort: "high", summary: "auto" } }, }, - { - id: "mixed", - body: { - reasoningEffort: "low", - reasoningSummary: "auto", - reasoning: { effort: "high", summary: "detailed" }, - }, - expected: { reasoning: { effort: "high", summary: "detailed" } }, - }, - { id: "plain", body: {}, expected: {} }, + { id: "plain", body: {} }, ] const models = { astra: { @@ -481,7 +464,7 @@ describe("OpencodePlugin", () => { Effect.gen(function* () { const projected = required(model.variants.find((item) => item.id === variant.id)) expect(projected.body).toEqual({ - ...variant.expected, + ...variant.body, include: ["reasoning.encrypted_content"], metadata: { custom: "unchanged" }, }) @@ -495,7 +478,7 @@ describe("OpencodePlugin", () => { const request = required(requests.at(-1)) expect(request.variant).toBe(variant.id) expect(request.body).toMatchObject({ - ...variant.expected, + ...variant.body, model: "api-astra", include: ["reasoning.encrypted_content"], metadata: { custom: "unchanged" }, @@ -508,9 +491,8 @@ describe("OpencodePlugin", () => { const compatible = required(yield* catalog.model.get(Provider.ID.make("compatible"), Model.ID.make("astra"))) const override = required(yield* catalog.model.get(Provider.ID.make("remote"), Model.ID.make("override"))) for (const model of [compatible, override]) { - expect(model.variants.find((variant) => variant.id === "legacy")?.body).toEqual({ - reasoningEffort: "high", - reasoningSummary: "auto", + expect(model.variants.find((variant) => variant.id === "native")?.body).toEqual({ + reasoning: { effort: "high", summary: "auto" }, include: ["reasoning.encrypted_content"], metadata: { custom: "unchanged" }, })