Skip to content

Commit e879f8d

Browse files
AntzCodeclaude
andauthored
feat(opencode-go): opt-in temperature for Responses models (#2055) (#2160)
* feat(opencode-go): opt-in temperature for Responses models (#2055) OpenCode Go Responses-format models now send temperature only for verified model and reasoning-effort combinations. This applies to both the streaming and non-streaming Responses requests. The settings UI uses the same rule: it hides the temperature control when the value would not be sent. Hiding the control does not clear or reset a saved temperature. - grok-4.6, muse-spark-1.3-contributor and muse-spark-1.2-contributor: temperature is sent at any reasoning effort. - gpt-5.6-luna and gpt-6-luna: temperature is sent only when the effective reasoning effort is "none". At other efforts the gateway returns HTTP 400 for every value except 1, which is the OpenAI reasoning default rather than real support, so the value is left out. - Temperature is sent only when the user has set a custom value. The provider default is never sent on this route. Changes: - types: add OPENCODE_GO_TEMPERATURE_REASONING_EFFORTS and opencodeGoResponsesSupportsTemperature(), and set supportsTemperature on every Responses model. - handler: add getResponsesTemperature(), which reads the raw modelTemperature setting and applies the opt-in rule; remove the unused temperature parameter from streamResponsesMessage; update the route comments so they no longer say the Responses route is Luna-only. - webview: add isTemperatureControlSupported(), which ApiOptions uses to decide whether to show TemperatureControl. It works out the effective reasoning effort the same way the request builder does. - tests: cover the rule, the model registry, the fetcher merge, both request modes, a stale "none" effort while reasoning is switched off, and the UI visibility round trip with the saved value kept. Shared transforms (getModelParams, RouterProvider) are unchanged. Refs #2006 Closes #2055 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(webview): add visual snapshot for OpenCode Go temperature visibility (#2055) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 333db91 commit e879f8d

13 files changed

Lines changed: 596 additions & 21 deletions

File tree

‎packages/types/src/__tests__/opencode-go.test.ts‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import {
88
isOpencodeGoAnthropicFormatModel,
99
isOpencodeGoResponsesFormatModel,
1010
getOpencodeGoModelInfo,
11+
OPENCODE_GO_TEMPERATURE_REASONING_EFFORTS,
12+
opencodeGoResponsesSupportsTemperature,
1113
} from "../providers/opencode-go.js"
14+
import { reasoningEffortsExtended } from "../model.js"
1215

1316
describe("opencode-go registry", () => {
1417
const anthropicFormatModels = [
@@ -170,6 +173,7 @@ describe("opencode-go registry", () => {
170173
it("curates gpt-5.6-luna with its Go Responses capabilities", () => {
171174
expect(getOpencodeGoModelInfo("gpt-5.6-luna")).toMatchObject({
172175
supportsMaxTokens: true,
176+
supportsTemperature: false,
173177
maxTokens: 128_000,
174178
contextWindow: 1_050_000,
175179
supportsImages: true,
@@ -221,6 +225,58 @@ describe("opencode-go registry", () => {
221225
})
222226
})
223227

228+
describe("opencodeGoResponsesSupportsTemperature (Zoo-Code-Org/Zoo-Code#2055)", () => {
229+
const gptLunaModels = ["gpt-5.6-luna", "gpt-6-luna"]
230+
const alwaysSupportedModels = ["grok-4.6", "muse-spark-1.3-contributor", "muse-spark-1.2-contributor"]
231+
232+
it.each(alwaysSupportedModels)("%s supports temperature for every effort and with none sent", (id) => {
233+
expect(getOpencodeGoModelInfo(id)?.supportsTemperature).toBe(true)
234+
expect(opencodeGoResponsesSupportsTemperature(id, undefined)).toBe(true)
235+
for (const effort of reasoningEffortsExtended) {
236+
expect(opencodeGoResponsesSupportsTemperature(id, effort)).toBe(true)
237+
}
238+
})
239+
240+
it.each(gptLunaModels)("%s supports temperature only with reasoning effort none", (id) => {
241+
expect(getOpencodeGoModelInfo(id)?.supportsTemperature).toBe(false)
242+
expect(opencodeGoResponsesSupportsTemperature(id, "none")).toBe(true)
243+
for (const effort of reasoningEffortsExtended.filter((e) => e !== "none")) {
244+
expect(opencodeGoResponsesSupportsTemperature(id, effort)).toBe(false)
245+
}
246+
// No effort on the wire is not a verified configuration.
247+
expect(opencodeGoResponsesSupportsTemperature(id, undefined)).toBe(false)
248+
})
249+
250+
it("lists only the GPT Luna models in the effort-conditional table", () => {
251+
expect(Object.keys(OPENCODE_GO_TEMPERATURE_REASONING_EFFORTS).sort()).toEqual(gptLunaModels)
252+
})
253+
254+
it("lists only advertised efforts for Responses models in the effort-conditional table", () => {
255+
for (const [id, efforts] of Object.entries(OPENCODE_GO_TEMPERATURE_REASONING_EFFORTS)) {
256+
expect(isOpencodeGoResponsesFormatModel(id)).toBe(true)
257+
// The table overrides a baseline opt-out, so the model must declare one.
258+
expect(getOpencodeGoModelInfo(id)?.supportsTemperature).toBe(false)
259+
const advertised = getOpencodeGoModelInfo(id)?.supportsReasoningEffort
260+
expect(Array.isArray(advertised)).toBe(true)
261+
for (const effort of efforts) {
262+
expect(advertised).toContain(effort)
263+
}
264+
}
265+
})
266+
267+
it("declares an explicit temperature capability for every Responses-format model", () => {
268+
for (const id of OPENCODE_GO_RESPONSES_FORMAT_MODELS) {
269+
expect(typeof getOpencodeGoModelInfo(id)?.supportsTemperature).toBe("boolean")
270+
}
271+
})
272+
273+
it("returns false for unknown and non-Responses models", () => {
274+
expect(opencodeGoResponsesSupportsTemperature("some-future-model", "none")).toBe(false)
275+
// kimi-k2.6 declares supportsTemperature: true but is not a Responses model.
276+
expect(opencodeGoResponsesSupportsTemperature("kimi-k2.6", undefined)).toBe(false)
277+
})
278+
})
279+
224280
describe("opencodeGoModels registry invariants", () => {
225281
it.each([
226282
{

‎packages/types/src/providers/opencode-go.ts‎

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ModelInfo } from "../model.js"
1+
import type { ModelInfo, ReasoningEffortExtended } from "../model.js"
22

33
// Opencode "Go" plan — OpenAI-compatible gateway.
44
// https://opencode.ai/docs/go/ · base URL: https://opencode.ai/zen/go/v1
@@ -574,6 +574,9 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
574574
supportsImages: true,
575575
supportsPromptCache: true,
576576
supportsMaxTokens: true,
577+
// Temperature is accepted only with reasoning effort "none"; see
578+
// OPENCODE_GO_TEMPERATURE_REASONING_EFFORTS.
579+
supportsTemperature: false,
577580
supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"],
578581
reasoningEffort: "medium",
579582
inputPrice: 0.2,
@@ -596,8 +599,8 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
596599
supportsImages: true,
597600
supportsPromptCache: true,
598601
supportsMaxTokens: true,
599-
// The OpenCode Go Responses model silently drops `temperature`, so the
600-
// UI temperature control would otherwise render as a dead control.
602+
// Temperature is accepted only with reasoning effort "none"; see
603+
// OPENCODE_GO_TEMPERATURE_REASONING_EFFORTS.
601604
supportsTemperature: false,
602605
supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"],
603606
reasoningEffort: "medium",
@@ -640,6 +643,7 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
640643
supportsImages: true,
641644
supportsPromptCache: true,
642645
supportsMaxTokens: true,
646+
supportsTemperature: true,
643647
supportsReasoningEffort: ["low", "medium", "high", "xhigh"],
644648
reasoningEffort: "high",
645649
inputPrice: 2.0,
@@ -660,6 +664,7 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
660664
supportsImages: true,
661665
supportsPromptCache: true,
662666
supportsMaxTokens: true,
667+
supportsTemperature: true,
663668
supportsReasoningEffort: ["minimal", "low", "medium", "high", "xhigh"],
664669
reasoningEffort: "medium",
665670
inputPrice: 0.1,
@@ -674,6 +679,7 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
674679
supportsImages: true,
675680
supportsPromptCache: true,
676681
supportsMaxTokens: true,
682+
supportsTemperature: true,
677683
supportsReasoningEffort: ["minimal", "low", "medium", "high", "xhigh"],
678684
reasoningEffort: "medium",
679685
inputPrice: 0.1,
@@ -760,6 +766,54 @@ export function isOpencodeGoResponsesFormatModel(modelId: string): boolean {
760766
return OPENCODE_GO_RESPONSES_FORMAT_MODELS.has(modelId)
761767
}
762768

769+
/**
770+
* Reasoning efforts for which a Responses-format model accepts `temperature`
771+
* even though its registry entry declares `supportsTemperature: false`.
772+
*
773+
* Live probes of the Go gateway (Zoo-Code-Org/Zoo-Code#2006) found that the
774+
* GPT Luna models accept every tested temperature (0–2) with reasoning effort
775+
* `"none"`. With any other effort they return HTTP 400 "unsupported
776+
* parameter" for every value except `1`. Temperature `1` is the OpenAI
777+
* reasoning-model default, so accepting it does not show real support: the
778+
* gateway allows only the default value. Temperature is therefore omitted for
779+
* every effort other than `"none"`, including a request that would send `1`
780+
* (Zoo-Code-Org/Zoo-Code#2055).
781+
*/
782+
export const OPENCODE_GO_TEMPERATURE_REASONING_EFFORTS: Readonly<Record<string, readonly ReasoningEffortExtended[]>> = {
783+
"gpt-5.6-luna": ["none"],
784+
"gpt-6-luna": ["none"],
785+
}
786+
787+
/**
788+
* Returns `true` when a Responses-format Go model accepts `temperature` for
789+
* the effective reasoning effort that will be sent on the wire.
790+
*
791+
* Support is opt-in (Zoo-Code-Org/Zoo-Code#2055): a Responses model must
792+
* declare `supportsTemperature: true` in the registry, or list the effort in
793+
* {@link OPENCODE_GO_TEMPERATURE_REASONING_EFFORTS}. A model without either
794+
* entry, or an unknown model ID, never receives `temperature`. Timeouts and
795+
* HTTP 5xx results are not evidence for or against support.
796+
*
797+
* @param modelId - The Go model ID.
798+
* @param reasoningEffort - The effective effort sent with the request, or
799+
* `undefined` when the request omits `reasoning.effort`.
800+
*/
801+
export function opencodeGoResponsesSupportsTemperature(
802+
modelId: string,
803+
reasoningEffort: ReasoningEffortExtended | undefined,
804+
): boolean {
805+
if (!isOpencodeGoResponsesFormatModel(modelId)) {
806+
return false
807+
}
808+
809+
const efforts = OPENCODE_GO_TEMPERATURE_REASONING_EFFORTS[modelId]
810+
if (efforts) {
811+
return reasoningEffort !== undefined && efforts.includes(reasoningEffort)
812+
}
813+
814+
return getOpencodeGoModelInfo(modelId)?.supportsTemperature === true
815+
}
816+
763817
/**
764818
* Returns the native {@link ModelInfo} for a Go-plan model ID, or `undefined`
765819
* when the ID is not part of the curated registry. Callers should fall back to

‎src/api/providers/__tests__/opencode-go.spec.ts‎

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ vitest.mock("../fetchers/modelCache", () => ({
4343
// Responses-format models (Zoo-Code-Org/Zoo-Code#1431 and issue #1979).
4444
"gpt-5.6-luna": { ...opencodeGoModels["gpt-5.6-luna"] },
4545
"gpt-6-luna": { ...opencodeGoModels["gpt-6-luna"] },
46+
"grok-4.6": { ...opencodeGoModels["grok-4.6"] },
47+
"muse-spark-1.3-contributor": { ...opencodeGoModels["muse-spark-1.3-contributor"] },
48+
"muse-spark-1.2-contributor": { ...opencodeGoModels["muse-spark-1.2-contributor"] },
4649
})
4750
}),
4851
refreshModels: vitest.fn().mockImplementation(function () {
@@ -51,6 +54,9 @@ vitest.mock("../fetchers/modelCache", () => ({
5154
"qwen3.7-max": { ...opencodeGoModels["qwen3.7-max"] },
5255
"gpt-5.6-luna": { ...opencodeGoModels["gpt-5.6-luna"] },
5356
"gpt-6-luna": { ...opencodeGoModels["gpt-6-luna"] },
57+
"grok-4.6": { ...opencodeGoModels["grok-4.6"] },
58+
"muse-spark-1.3-contributor": { ...opencodeGoModels["muse-spark-1.3-contributor"] },
59+
"muse-spark-1.2-contributor": { ...opencodeGoModels["muse-spark-1.2-contributor"] },
5460
})
5561
}),
5662
getModelsFromCache: vitest.fn().mockReturnValue(undefined),
@@ -1115,7 +1121,7 @@ describe("OpencodeGoHandler", () => {
11151121
expect(callArgs.store).toBe(false)
11161122
const input = callArgs.input as unknown[]
11171123
expect(input.some((item) => (item as { role?: string }).role === "system")).toBe(false)
1118-
// The gateway rejects temperature for Responses-format models.
1124+
// No custom temperature is set, so the provider default is not sent.
11191125
expect(callArgs.temperature).toBeUndefined()
11201126
// No tools were provided, so no tools/tool_choice are sent.
11211127
expect(callArgs.tools).toBeUndefined()
@@ -1500,6 +1506,141 @@ describe("OpencodeGoHandler", () => {
15001506
}).rejects.toThrow("Opencode Go completion error: internal server error")
15011507
})
15021508

1509+
describe("temperature (Zoo-Code-Org/Zoo-Code#2055)", () => {
1510+
const messages: Anthropic.Messages.MessageParam[] = [{ role: "user", content: "Hi" }]
1511+
1512+
const streamRequest = async (options: ApiHandlerOptions) => {
1513+
await collectStream(new OpencodeGoHandler(options).createMessage("sys", messages))
1514+
return mockResponsesCreate.mock.calls[0][0] as Record<string, unknown>
1515+
}
1516+
1517+
const completeRequest = async (options: ApiHandlerOptions) => {
1518+
mockResponsesCreate.mockResolvedValue({ output_text: "Hello!" })
1519+
await new OpencodeGoHandler(options).completePrompt("ping")
1520+
return mockResponsesCreate.mock.calls[0][0] as Record<string, unknown>
1521+
}
1522+
1523+
const paths = [
1524+
["streaming", streamRequest],
1525+
["non-streaming", completeRequest],
1526+
] as const
1527+
1528+
describe.each(paths)("%s request", (_path, sendRequest) => {
1529+
it.each([
1530+
["grok-4.6", undefined],
1531+
["muse-spark-1.3-contributor", undefined],
1532+
["muse-spark-1.2-contributor", undefined],
1533+
["gpt-5.6-luna", "none"],
1534+
["gpt-6-luna", "none"],
1535+
] as const)("forwards a custom temperature for %s (effort %s)", async (modelId, reasoningEffort) => {
1536+
const callArgs = await sendRequest({
1537+
opencodeGoApiKey: "test-key",
1538+
opencodeGoModelId: modelId,
1539+
modelTemperature: 0.37,
1540+
...(reasoningEffort && { reasoningEffort }),
1541+
})
1542+
1543+
// The value keeps the UI's 0.01 resolution.
1544+
expect(callArgs.temperature).toBe(0.37)
1545+
})
1546+
1547+
it.each([
1548+
["grok-4.6", "low"],
1549+
["grok-4.6", "high"],
1550+
["muse-spark-1.3-contributor", "minimal"],
1551+
["muse-spark-1.2-contributor", "high"],
1552+
] as const)(
1553+
"forwards a custom temperature for %s with explicit effort %s",
1554+
async (modelId, reasoningEffort) => {
1555+
const callArgs = await sendRequest({
1556+
opencodeGoApiKey: "test-key",
1557+
opencodeGoModelId: modelId,
1558+
modelTemperature: 0.37,
1559+
reasoningEffort,
1560+
})
1561+
1562+
// Grok and Muse support does not depend on reasoning effort.
1563+
expect(callArgs.reasoning).toEqual({ effort: reasoningEffort })
1564+
expect(callArgs.temperature).toBe(0.37)
1565+
},
1566+
)
1567+
1568+
it("omits temperature for a stale none effort when reasoning effort is switched off", async () => {
1569+
// A saved "none" does not reach the wire while the toggle is off,
1570+
// so the configuration is unverified and temperature is omitted.
1571+
const callArgs = await sendRequest({
1572+
...lunaOptions,
1573+
modelTemperature: 0.5,
1574+
reasoningEffort: "none",
1575+
enableReasoningEffort: false,
1576+
})
1577+
1578+
expect(callArgs).not.toHaveProperty("reasoning")
1579+
expect(callArgs).not.toHaveProperty("temperature")
1580+
})
1581+
1582+
it.each([
1583+
["gpt-5.6-luna", "low"],
1584+
["gpt-5.6-luna", "max"],
1585+
["gpt-6-luna", "medium"],
1586+
["gpt-6-luna", "xhigh"],
1587+
["gpt-6-luna", "disable"],
1588+
] as const)("omits a saved temperature for %s with effort %s", async (modelId, reasoningEffort) => {
1589+
const callArgs = await sendRequest({
1590+
opencodeGoApiKey: "test-key",
1591+
opencodeGoModelId: modelId,
1592+
modelTemperature: 0.5,
1593+
reasoningEffort,
1594+
})
1595+
1596+
expect(callArgs).not.toHaveProperty("temperature")
1597+
})
1598+
1599+
it("omits temperature 1 for a GPT Luna model with a non-none effort", async () => {
1600+
// Temperature 1 is the only value the gateway accepted with
1601+
// reasoning, but it is the model default, so it is omitted.
1602+
const callArgs = await sendRequest({
1603+
opencodeGoApiKey: "test-key",
1604+
opencodeGoModelId: "gpt-5.6-luna",
1605+
modelTemperature: 1,
1606+
reasoningEffort: "high",
1607+
})
1608+
1609+
expect(callArgs).not.toHaveProperty("temperature")
1610+
})
1611+
1612+
it("omits a saved temperature for a GPT Luna model on its default effort", async () => {
1613+
const callArgs = await sendRequest({ ...gpt6LunaOptions, modelTemperature: 0.5 })
1614+
1615+
expect(callArgs.reasoning).toEqual({ effort: "medium" })
1616+
expect(callArgs).not.toHaveProperty("temperature")
1617+
})
1618+
1619+
it.each([undefined, null])(
1620+
"omits temperature when no custom value is set (%s)",
1621+
async (modelTemperature) => {
1622+
const callArgs = await sendRequest({
1623+
opencodeGoApiKey: "test-key",
1624+
opencodeGoModelId: "grok-4.6",
1625+
modelTemperature,
1626+
})
1627+
1628+
expect(callArgs).not.toHaveProperty("temperature")
1629+
},
1630+
)
1631+
1632+
it("forwards temperature 0 as an explicit custom value", async () => {
1633+
const callArgs = await sendRequest({
1634+
opencodeGoApiKey: "test-key",
1635+
opencodeGoModelId: "grok-4.6",
1636+
modelTemperature: 0,
1637+
})
1638+
1639+
expect(callArgs.temperature).toBe(0)
1640+
})
1641+
})
1642+
})
1643+
15031644
it("classifies documented Responses models as Responses-format and other models as not", () => {
15041645
expect(isOpencodeGoResponsesFormatModel("gpt-5.6-luna")).toBe(true)
15051646
expect(isOpencodeGoResponsesFormatModel("gpt-6-luna")).toBe(true)

‎src/api/providers/fetchers/__tests__/opencode-go.spec.ts‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,26 @@ describe("Opencode Go Fetchers", () => {
7575
})
7676
})
7777

78+
it("keeps curated Responses temperature support after merging live metadata", async () => {
79+
mockedAxios.get.mockResolvedValue({
80+
data: {
81+
data: [
82+
{ id: "grok-4.6", context_window: 400_000 },
83+
{ id: "muse-spark-1.2-contributor", max_tokens: 65_536 },
84+
{ id: "gpt-5.6-luna", context_window: 900_000 },
85+
],
86+
},
87+
})
88+
89+
const models = await getOpencodeGoModels("k")
90+
91+
// Live limits never override the curated temperature capability
92+
// (Zoo-Code-Org/Zoo-Code#2055).
93+
expect(models["grok-4.6"]).toMatchObject({ contextWindow: 400_000, supportsTemperature: true })
94+
expect(models["muse-spark-1.2-contributor"]).toMatchObject({ maxTokens: 65_536, supportsTemperature: true })
95+
expect(models["gpt-5.6-luna"]).toMatchObject({ contextWindow: 900_000, supportsTemperature: false })
96+
})
97+
7898
it("uses curated gpt-6-luna metadata when the live model omits metadata", async () => {
7999
mockedAxios.get.mockResolvedValue({ data: { data: [{ id: "gpt-6-luna" }] } })
80100

@@ -86,9 +106,9 @@ describe("Opencode Go Fetchers", () => {
86106
supportsImages: true,
87107
supportsPromptCache: true,
88108
supportsMaxTokens: true,
89-
// The Opencode Go Responses gateway rejects `temperature` for
90-
// `gpt-6-luna`, so the curated registry must opt out so the UI
91-
// hides the dead control rather than rendering it.
109+
// The Go gateway accepts `temperature` for `gpt-6-luna` only with
110+
// reasoning effort "none", so the static baseline opts out and the
111+
// effort-aware rule opts back in (Zoo-Code-Org/Zoo-Code#2055).
92112
supportsTemperature: false,
93113
supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"],
94114
reasoningEffort: "medium",

0 commit comments

Comments
 (0)