Skip to content

Commit 89d43bc

Browse files
AntzCodenavedmerchant
authored andcommitted
[Fix] Opencode Go routes gpt-5.6-luna through /v1/responses (Zoo-Code-Org#1443)
* [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 Zoo-Code-Org#1431 * [Fix] Opencode Go routes gpt-5.6-luna through /v1/responses Address CodeRabbit and Codecov findings from PR Zoo-Code-Org#1443. --------- Co-authored-by: Naved Merchant <[email protected]> (cherry picked from commit a80b3b3)
1 parent 0852093 commit 89d43bc

4 files changed

Lines changed: 932 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: 63 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
*
@@ -358,6 +359,30 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
358359
description:
359360
"DeepSeek-V4-Flash is DeepSeek's fast, cost-efficient V4 model supporting thinking and non-thinking modes. Available via the Opencode Go plan.",
360361
},
362+
// --- OpenAI Responses ---
363+
// Luna is curated here because the Go gateway's model catalogue does not
364+
// currently provide its capability metadata. These values intentionally
365+
// describe the Go Responses route, not the OpenAI-native or Codex routes.
366+
"gpt-5.6-luna": {
367+
maxTokens: 128_000,
368+
contextWindow: 1_050_000,
369+
supportsImages: true,
370+
supportsPromptCache: true,
371+
supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"],
372+
reasoningEffort: "medium",
373+
inputPrice: 0.2,
374+
outputPrice: 1.2,
375+
cacheWritesPrice: 0.25,
376+
cacheReadsPrice: 0.02,
377+
longContextPricing: {
378+
thresholdTokens: 272_000,
379+
inputPriceMultiplier: 2,
380+
outputPriceMultiplier: 1.5,
381+
cacheWritesPriceMultiplier: 2,
382+
cacheReadsPriceMultiplier: 2,
383+
},
384+
description: "GPT-5.6 Luna via the OpenCode Go Responses API.",
385+
},
361386
}
362387

363388
/**
@@ -388,16 +413,48 @@ export const OPENCODE_GO_ANTHROPIC_FORMAT_MODELS = new Set<string>([
388413
"minimax-m2.5",
389414
])
390415

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

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

0 commit comments

Comments
 (0)