Skip to content

Commit c08c3c0

Browse files
committed
[Fix] Opencode Go routes gpt-5.6-luna through /v1/responses
Routes gpt-5.6-luna through the Responses API required by the Opencode Go gateway. Fixes #1431
1 parent b55ff87 commit c08c3c0

4 files changed

Lines changed: 663 additions & 36 deletions

File tree

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import {
44
opencodeGoModels,
55
OPENCODE_GO_DEFAULT_TEMPERATURE,
66
OPENCODE_GO_ANTHROPIC_FORMAT_MODELS,
7+
OPENCODE_GO_RESPONSES_FORMAT_MODELS,
78
isOpencodeGoAnthropicFormatModel,
9+
isOpencodeGoResponsesFormatModel,
810
getOpencodeGoModelInfo,
911
} from "../providers/opencode-go.js"
1012

@@ -129,6 +131,58 @@ describe("opencode-go registry", () => {
129131
})
130132
})
131133

134+
describe("OPENCODE_GO_RESPONSES_FORMAT_MODELS", () => {
135+
it("contains exactly the Responses-only models", () => {
136+
expect([...OPENCODE_GO_RESPONSES_FORMAT_MODELS].sort()).toEqual(["gpt-5.6-luna"])
137+
})
138+
139+
it("classifies gpt-5.6-luna as Responses-format", () => {
140+
expect(isOpencodeGoResponsesFormatModel("gpt-5.6-luna")).toBe(true)
141+
})
142+
143+
it("classifies Anthropic-format and OpenAI-compatible models as non-Responses-format", () => {
144+
for (const id of anthropicFormatModels) {
145+
expect(isOpencodeGoResponsesFormatModel(id)).toBe(false)
146+
}
147+
for (const id of openaiFormatModels) {
148+
expect(isOpencodeGoResponsesFormatModel(id)).toBe(false)
149+
}
150+
})
151+
152+
it("defaults unknown model IDs to the OpenAI-compatible format", () => {
153+
expect(isOpencodeGoResponsesFormatModel("some-future-model")).toBe(false)
154+
expect(isOpencodeGoResponsesFormatModel("")).toBe(false)
155+
})
156+
157+
it("curates gpt-5.6-luna with its Go Responses capabilities", () => {
158+
expect(getOpencodeGoModelInfo("gpt-5.6-luna")).toMatchObject({
159+
maxTokens: 128_000,
160+
contextWindow: 1_050_000,
161+
supportsImages: true,
162+
supportsPromptCache: true,
163+
supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"],
164+
reasoningEffort: "medium",
165+
inputPrice: 0.2,
166+
outputPrice: 1.2,
167+
cacheWritesPrice: 0.25,
168+
cacheReadsPrice: 0.02,
169+
longContextPricing: {
170+
thresholdTokens: 272_000,
171+
inputPriceMultiplier: 2,
172+
outputPriceMultiplier: 1.5,
173+
cacheWritesPriceMultiplier: 2,
174+
cacheReadsPriceMultiplier: 2,
175+
},
176+
})
177+
})
178+
179+
it("is disjoint from the Anthropic-format set", () => {
180+
for (const id of OPENCODE_GO_RESPONSES_FORMAT_MODELS) {
181+
expect(OPENCODE_GO_ANTHROPIC_FORMAT_MODELS.has(id)).toBe(false)
182+
}
183+
})
184+
})
185+
132186
describe("opencodeGoModels registry invariants", () => {
133187
it("every entry has a positive maxTokens and contextWindow", () => {
134188
for (const [id, info] of Object.entries(opencodeGoModels)) {

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

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ export const OPENCODE_GO_DEFAULT_TEMPERATURE = 0
3434
* This registry encodes the native capabilities of each curated Go model,
3535
* sourced from the same vendor specs used by the dedicated providers
3636
* (zai/moonshot/mimo/minimax/deepseek/qwen) and the Go pricing table at
37-
* https://opencode.ai/docs/go/#usage-limits. The fetcher merges the live
38-
* `/models` payload on top of these defaults so that context-window and
39-
* max-token values stay in sync with the gateway while capability flags and
40-
* pricing remain correct.
37+
* https://opencode.ai/docs/go/#usage-limits. It also includes explicitly
38+
* curated Responses-format models whose gateway metadata is not available
39+
* through `/models`. The fetcher merges the live `/models` payload on top of
40+
* these defaults so that context-window and max-token values stay in sync
41+
* with the gateway while capability flags and pricing remain correct.
4142
*
4243
* `supportsPromptCache` has two distinct meanings depending on the wire format:
4344
*
@@ -343,6 +344,31 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
343344
description:
344345
"DeepSeek-V4-Pro-0813 is DeepSeek's strongest V4 model for reasoning, coding, long-context, and agentic workloads. Available via the Opencode Go plan.",
345346
},
347+
// --- OpenAI Responses ---
348+
// Luna is curated here because the Go gateway's model catalogue does not
349+
// currently provide its capability metadata. These values intentionally
350+
// describe the Go Responses route, not the OpenAI-native or Codex routes.
351+
"gpt-5.6-luna": {
352+
maxTokens: 128_000,
353+
contextWindow: 1_050_000,
354+
supportsImages: true,
355+
supportsPromptCache: true,
356+
supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"],
357+
reasoningEffort: "medium",
358+
inputPrice: 0.2,
359+
outputPrice: 1.2,
360+
cacheWritesPrice: 0.25,
361+
cacheReadsPrice: 0.02,
362+
longContextPricing: {
363+
thresholdTokens: 272_000,
364+
inputPriceMultiplier: 2,
365+
outputPriceMultiplier: 1.5,
366+
cacheWritesPriceMultiplier: 2,
367+
cacheReadsPriceMultiplier: 2,
368+
},
369+
description: "GPT-5.6 Luna via the OpenCode Go Responses API.",
370+
},
371+
346372
"deepseek-v4-flash": {
347373
maxTokens: 384_000,
348374
contextWindow: 1_000_000,
@@ -388,16 +414,48 @@ export const OPENCODE_GO_ANTHROPIC_FORMAT_MODELS = new Set<string>([
388414
"minimax-m2.5",
389415
])
390416

417+
/**
418+
* OpenCode Go models that must be requested via the OpenAI Responses API
419+
* (`/v1/responses`), not the OpenAI-compatible Chat Completions endpoint
420+
* (`/v1/chat/completions`).
421+
*
422+
* The Go gateway maps every model to exactly one wire format. Some models
423+
* (currently only `gpt-5.6-luna`) are Responses-only and are also explicitly
424+
* curated in `opencodeGoModels`: the gateway's
425+
* `/v1/chat/completions` adapter for them fails with an opaque HTTP 500
426+
* (`{"type":"error","error":{"type":"error","message":"Internal server error"}}`),
427+
* while `/v1/responses` succeeds (Zoo-Code-Org/Zoo-Code#1431).
428+
*
429+
* Drive routing from this set rather than from the model ID string so the
430+
* gateway's protocol contract stays explicit, testable, and easy to extend
431+
* when the next Responses-only model lands. Unknown model IDs default to the
432+
* OpenAI-compatible chat completions format.
433+
*/
434+
export const OPENCODE_GO_RESPONSES_FORMAT_MODELS = new Set<string>([
435+
// --- OpenAI ---
436+
"gpt-5.6-luna",
437+
])
438+
391439
/**
392440
* Returns `true` when the given Go-plan model ID must be requested via the
393441
* Anthropic Messages format (`/v1/messages`) rather than the OpenAI-compatible
394-
* chat completions format. Unknown (non-curated) model IDs default to the
395-
* OpenAI-compatible format, matching the gateway's default routing.
442+
* chat completions format. Unknown model IDs default to the OpenAI-compatible
443+
* format, matching the gateway's default routing.
396444
*/
397445
export function isOpencodeGoAnthropicFormatModel(modelId: string): boolean {
398446
return OPENCODE_GO_ANTHROPIC_FORMAT_MODELS.has(modelId)
399447
}
400448

449+
/**
450+
* Returns `true` when the given Go-plan model ID must be requested via the
451+
* OpenAI Responses API (`/v1/responses`) rather than the OpenAI-compatible
452+
* chat completions format. Unknown model IDs default to the OpenAI-compatible
453+
* format, matching the gateway's default routing.
454+
*/
455+
export function isOpencodeGoResponsesFormatModel(modelId: string): boolean {
456+
return OPENCODE_GO_RESPONSES_FORMAT_MODELS.has(modelId)
457+
}
458+
401459
/**
402460
* Returns the native {@link ModelInfo} for a Go-plan model ID, or `undefined`
403461
* when the ID is not part of the curated registry. Callers should fall back to

0 commit comments

Comments
 (0)