Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/types/src/__tests__/opencode-go.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe("opencode-go registry", () => {
]
const responsesFormatModels = [
"gpt-5.6-luna",
"gpt-6-luna",
"grok-4.6",
"muse-spark-1.3-contributor",
"muse-spark-1.2-contributor",
Expand Down Expand Up @@ -189,6 +190,30 @@ describe("opencode-go registry", () => {
})
})

it("curates gpt-6-luna with its documented Responses capabilities and pricing", () => {
expect(getOpencodeGoModelInfo("gpt-6-luna")).toMatchObject({
maxTokens: 128_000,
supportsMaxTokens: true,
supportsTemperature: false,
contextWindow: 1_050_000,
supportsImages: true,
supportsPromptCache: true,
supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"],
reasoningEffort: "medium",
inputPrice: 0.1,
outputPrice: 0.5,
cacheWritesPrice: 0.125,
cacheReadsPrice: 0.01,
longContextPricing: {
thresholdTokens: 272_000,
inputPriceMultiplier: 2,
outputPriceMultiplier: 1.5,
cacheWritesPriceMultiplier: 2,
cacheReadsPriceMultiplier: 2,
},
})
})

it("is disjoint from the Anthropic-format set", () => {
for (const id of OPENCODE_GO_RESPONSES_FORMAT_MODELS) {
expect(OPENCODE_GO_ANTHROPIC_FORMAT_MODELS.has(id)).toBe(false)
Expand Down
29 changes: 27 additions & 2 deletions packages/types/src/providers/opencode-go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@
},

// --- OpenAI Responses ---
// Luna is curated here because the Go gateway's model catalogue does not
// currently provide its capability metadata. These values intentionally
// Luna models are curated here because the Go gateway's model catalogue does
// not currently provide their capability metadata. These values intentionally
// describe the Go Responses route, not the OpenAI-native or Codex routes.
"gpt-5.6-luna": {
maxTokens: 128_000,
Expand All @@ -590,6 +590,30 @@
description:
"GPT-5.6 Luna is OpenAI's fast reasoning model with a 1M context window. Available via the Opencode Go plan.",
},
"gpt-6-luna": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking follow-up: the new model entry does not explicitly disable temperature, so the settings UI exposes a control that the Responses handler silently ignores. The same inconsistency exists for GPT-5.6 Luna.

The settings UI condition displays this control unless the model explicitly marks temperature as unsupported. Meanwhile, both the streaming Responses path and the non-streaming Responses path omit temperature, with comments stating that the Go Responses API rejects it. This review did not independently verify that behavior against the live gateway.

I suggest creating a separate issue rather than blocking this PR, to:

  • Verify with authenticated requests whether the Go Responses API rejects temperature for both GPT-6 Luna and GPT-5.6 Luna, including whether support depends on reasoning effort.
  • If rejection is confirmed, explicitly mark temperature as unsupported for the affected models so the UI no longer offers an ineffective control.
  • Add a short comment explaining why temperature is disabled, with a reference to the issue or provider documentation recording the verification.
  • Add regression coverage for the capability flag and its propagation through the model fetcher.

The protocol-routing fix in this PR can proceed independently of that follow-up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that. I have configured the UI to hide the temperature control, to prevent user confusion. I have not extended this to gpt-5.6-luna or other responses models as outside scope for the reported issue.

I'd be happy to take on the task you described, to investigate and document the feature support for currently named models, would you like me to create that task?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maxTokens: 128_000,
contextWindow: 1_050_000,
supportsImages: true,
supportsPromptCache: true,
supportsMaxTokens: true,
// The OpenCode Go Responses model silently drops `temperature`, so the
// UI temperature control would otherwise render as a dead control.
supportsTemperature: false,
supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"],
reasoningEffort: "medium",
inputPrice: 0.1,
outputPrice: 0.5,
cacheWritesPrice: 0.125,
cacheReadsPrice: 0.01,
longContextPricing: {
thresholdTokens: 272_000,
inputPriceMultiplier: 2,
outputPriceMultiplier: 1.5,
cacheWritesPriceMultiplier: 2,
cacheReadsPriceMultiplier: 2,
},
description: "GPT-6 Luna via the OpenCode Go Responses API.",

Check warning on line 615 in packages/types/src/providers/opencode-go.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

packages/types/src/providers/opencode-go.ts:615: Survived StringLiteral mutant (replacement: ""). See the job summary for the complete list and resolution guidance.
},
"grok-4.5": {
maxTokens: 500_000,
contextWindow: 500_000,
Expand Down Expand Up @@ -708,6 +732,7 @@
export const OPENCODE_GO_RESPONSES_FORMAT_MODELS = new Set<string>([
// --- OpenAI ---
"gpt-5.6-luna",
"gpt-6-luna",
// --- xAI ---
"grok-4.6",
// --- Meta ---
Expand Down
40 changes: 38 additions & 2 deletions src/api/providers/__tests__/opencode-go.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ vitest.mock("../fetchers/modelCache", () => ({
"glm-5.1": { ...opencodeGoModels["glm-5.1"] },
// Anthropic-format model used to exercise the /v1/messages path.
"qwen3.7-max": { ...opencodeGoModels["qwen3.7-max"] },
// Responses-format model (Zoo-Code-Org/Zoo-Code#1431).
// Responses-format models (Zoo-Code-Org/Zoo-Code#1431 and issue #1979).
"gpt-5.6-luna": { ...opencodeGoModels["gpt-5.6-luna"] },
"gpt-6-luna": { ...opencodeGoModels["gpt-6-luna"] },
})
}),
refreshModels: vitest.fn().mockImplementation(function () {
return Promise.resolve({
"glm-5.1": { ...opencodeGoModels["glm-5.1"] },
"qwen3.7-max": { ...opencodeGoModels["qwen3.7-max"] },
"gpt-5.6-luna": { ...opencodeGoModels["gpt-5.6-luna"] },
"gpt-6-luna": { ...opencodeGoModels["gpt-6-luna"] },
})
}),
getModelsFromCache: vitest.fn().mockReturnValue(undefined),
Expand Down Expand Up @@ -833,7 +835,7 @@ describe("OpencodeGoHandler", () => {
})
})

describe("Responses-format models (gpt-5.6-luna)", () => {
describe("Responses-format models (gpt-5.6-luna, gpt-6-luna)", () => {
// gpt-5.6-luna is Responses-only on the Go gateway: its chat-completions
// adapter fails with an opaque HTTP 500 (Zoo-Code-Org/Zoo-Code#1431),
// so the handler must route it through /v1/responses and never fall
Expand All @@ -842,6 +844,10 @@ describe("OpencodeGoHandler", () => {
opencodeGoApiKey: "test-key",
opencodeGoModelId: "gpt-5.6-luna",
}
const gpt6LunaOptions: ApiHandlerOptions = {
opencodeGoApiKey: "test-key",
opencodeGoModelId: "gpt-6-luna",
}

beforeEach(() => {
mockResponsesCreate.mockImplementation(async () =>
Expand Down Expand Up @@ -982,6 +988,21 @@ describe("OpencodeGoHandler", () => {
expect(mockAnthropicCreate).not.toHaveBeenCalled()
})

it("routes gpt-6-luna streaming through responses.create only", async () => {
const handler = new OpencodeGoHandler(gpt6LunaOptions)
const messages: Anthropic.Messages.MessageParam[] = [{ role: "user", content: "Hi" }]

const chunks = await collectStream(handler.createMessage("sys", messages))

expect(chunks).toContainEqual({ type: "text", text: "Hello" })
expect(mockResponsesCreate).toHaveBeenCalledWith(
expect.objectContaining({ model: "gpt-6-luna", stream: true }),
expect.anything(),
)
expect(mockCreate).not.toHaveBeenCalled()
expect(mockAnthropicCreate).not.toHaveBeenCalled()
})

it("streams text and reasoning chunks from the Responses event stream", async () => {
const handler = new OpencodeGoHandler(lunaOptions)
const messages: Anthropic.Messages.MessageParam[] = [{ role: "user", content: "Hi" }]
Expand Down Expand Up @@ -1315,6 +1336,20 @@ describe("OpencodeGoHandler", () => {
expect(callArgs.temperature).toBeUndefined()
})

it("completePrompt routes gpt-6-luna through responses.create only", async () => {
mockResponsesCreate.mockResolvedValue({ output_text: "Luna 6 response" })
const handler = new OpencodeGoHandler(gpt6LunaOptions)

expect(await handler.completePrompt("ping")).toBe("Luna 6 response")

expect(mockResponsesCreate).toHaveBeenCalledWith(
expect.objectContaining({ model: "gpt-6-luna", store: false }),
expect.anything(),
)
expect(mockCreate).not.toHaveBeenCalled()
expect(mockAnthropicCreate).not.toHaveBeenCalled()
})

it("forwards Responses-specific max_output_tokens and reasoning in completePrompt", async () => {
mockResponsesCreate.mockResolvedValue({ output_text: "Hello!" })
const handler = new OpencodeGoHandler({ ...lunaOptions, includeMaxTokens: true, modelMaxTokens: 7_500 })
Expand Down Expand Up @@ -1364,6 +1399,7 @@ describe("OpencodeGoHandler", () => {

it("classifies documented Responses models as Responses-format and other models as not", () => {
expect(isOpencodeGoResponsesFormatModel("gpt-5.6-luna")).toBe(true)
expect(isOpencodeGoResponsesFormatModel("gpt-6-luna")).toBe(true)
expect(isOpencodeGoResponsesFormatModel("grok-4.5")).toBe(false)
expect(isOpencodeGoResponsesFormatModel("grok-4.6")).toBe(true)
expect(isOpencodeGoResponsesFormatModel("muse-spark-1.3-contributor")).toBe(true)
Expand Down
39 changes: 39 additions & 0 deletions src/api/providers/fetchers/__tests__/opencode-go.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,30 @@ describe("Opencode Go Fetchers", () => {
})
})

it("uses curated gpt-6-luna metadata when the live model omits metadata", async () => {
mockedAxios.get.mockResolvedValue({ data: { data: [{ id: "gpt-6-luna" }] } })

const models = await getOpencodeGoModels("k")

expect(models["gpt-6-luna"]).toMatchObject({
contextWindow: 1_050_000,
maxTokens: 128_000,
supportsImages: true,
supportsPromptCache: true,
supportsMaxTokens: true,
// The Opencode Go Responses gateway rejects `temperature` for
// `gpt-6-luna`, so the curated registry must opt out so the UI
// hides the dead control rather than rendering it.
supportsTemperature: false,
supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"],
reasoningEffort: "medium",
inputPrice: 0.1,
outputPrice: 0.5,
cacheWritesPrice: 0.125,
cacheReadsPrice: 0.01,
})
})

it("falls back to default context/max tokens for an unknown model when metadata is absent", async () => {
mockedAxios.get.mockResolvedValue({ data: { data: [{ id: "some-unknown-model" }] } })

Expand Down Expand Up @@ -213,6 +237,7 @@ describe("Opencode Go Fetchers", () => {
"hy3",
"hy3-preview",
"gpt-5.6-luna",
"gpt-6-luna",
"grok-4.5",
"grok-4.6",
"muse-spark-1.3-contributor",
Expand Down Expand Up @@ -248,6 +273,20 @@ describe("Opencode Go Fetchers", () => {
expect(info.inputPrice).toBe(1.4)
})

it("keeps gpt-6-luna live limits authoritative over its curated metadata", () => {
const info = parseOpencodeGoModel({
id: "gpt-6-luna",
context_window: 1_000_000,
max_output_tokens: 64_000,
})

expect(info.contextWindow).toBe(1_000_000)
expect(info.maxTokens).toBe(64_000)
expect(info.supportsImages).toBe(true)
expect(info.inputPrice).toBe(0.1)
expect(info.cacheWritesPrice).toBe(0.125)
})

it("uses native registry defaults when the live payload omits volatile fields", () => {
const info = parseOpencodeGoModel({ id: "deepseek-v4-flash" })
const native = getOpencodeGoModelInfo("deepseek-v4-flash")!
Expand Down
10 changes: 5 additions & 5 deletions src/api/providers/opencode-go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ type OpencodeGoFormat = "anthropic" | "openai" | "responses"
* - Anthropic Messages (`/v1/messages`) — used by Qwen (qwen3.8-max,
* qwen3.7-max, qwen3.7-plus, qwen3.6-plus) and MiniMax (minimax-m3,
* minimax-m2.7, minimax-m2.5) models.
* - OpenAI Responses (`/v1/responses`) — used by gpt-5.6-luna, whose
* chat-completions adapter fails with an opaque HTTP 500
* (Zoo-Code-Org/Zoo-Code#1431).
* - OpenAI Responses (`/v1/responses`) — used by `gpt-5.6-luna` and
* `gpt-6-luna`, whose chat-completions adapters are not supported by the
* Go gateway.
*
* Sending an Anthropic-format model to the chat completions endpoint is
* rejected with `401 Model <id> is not supported for format oa-compat`, so this
Expand Down Expand Up @@ -183,7 +183,7 @@ export class OpencodeGoHandler extends RouterProvider implements SingleCompletio
*
* Anthropic-format models (Qwen/MiniMax) are streamed via
* {@link streamAnthropicMessage} against `/v1/messages`; Responses-format
* models (gpt-5.6-luna) are streamed via {@link streamResponsesMessage}
* models (`gpt-5.6-luna` and `gpt-6-luna`) are streamed via {@link streamResponsesMessage}
* against `/v1/responses`; all other models use the OpenAI-compatible chat
* completions endpoint.
*
Expand Down Expand Up @@ -292,7 +292,7 @@ export class OpencodeGoHandler extends RouterProvider implements SingleCompletio

/**
* Streams an OpenAI Responses-format completion for Go models that only
* accept the `/v1/responses` endpoint (currently gpt-5.6-luna).
* accept the `/v1/responses` endpoint (`gpt-5.6-luna` and `gpt-6-luna`).
*
* Follows the focused xAI handler pattern: the conversation is converted
* with the shared {@link convertToResponsesApiInput} transform, the system
Expand Down
Loading