Repository navigation
fix(opencode-go): route GPT-5.6+ models through Responses API #1988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -658,6 +658,27 @@ | |
| description: | ||
| "Muse Spark 1.2 Contributor is Meta's multimodal coding model with a 1M context window. Available via the Opencode Go plan.", | ||
| }, | ||
| "gpt-6-luna": { | ||
| maxTokens: 128_000, | ||
| contextWindow: 1_050_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| supportsMaxTokens: true, | ||
| supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"], | ||
|
Check warning on line 667 in packages/types/src/providers/opencode-go.ts
|
||
| reasoningEffort: "medium", | ||
|
Check warning on line 668 in packages/types/src/providers/opencode-go.ts
|
||
| inputPrice: 0.1, | ||
| outputPrice: 0.5, | ||
| cacheWritesPrice: 0.13, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the OpenCode documentation, the correct price is $0.125: |
||
| cacheReadsPrice: 0.01, | ||
| longContextPricing: { | ||
|
Check warning on line 673 in packages/types/src/providers/opencode-go.ts
|
||
| 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 680 in packages/types/src/providers/opencode-go.ts
|
||
| }, | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -694,27 +715,21 @@ | |
| * (`/v1/responses`), not the OpenAI-compatible Chat Completions endpoint | ||
| * (`/v1/chat/completions`). | ||
| * | ||
| * The Go gateway maps every model to exactly one wire format. Responses-only | ||
| * models are explicitly curated in `opencodeGoModels`: the gateway's | ||
| * `/v1/chat/completions` adapter for these models can fail with an opaque HTTP 500 | ||
| * (`{"type":"error","error":{"type":"error","message":"Internal server error"}}`), | ||
| * while `/v1/responses` succeeds (Zoo-Code-Org/Zoo-Code#1431). | ||
| * | ||
| * Drive routing from this set rather than from the model ID string so the | ||
| * gateway's protocol contract stays explicit, testable, and easy to extend | ||
| * when the next Responses-only model lands. Unknown model IDs default to the | ||
| * OpenAI-compatible chat completions format. | ||
| * The Go gateway maps known non-GPT Responses models explicitly, while GPT-5.6 | ||
| * and later numeric GPT generations are routed by pattern. The separate `gpt-oss` | ||
| * family remains on Chat Completions. | ||
| */ | ||
| export const OPENCODE_GO_RESPONSES_FORMAT_MODELS = new Set<string>([ | ||
| // --- OpenAI --- | ||
| "gpt-5.6-luna", | ||
| // --- xAI --- | ||
| "grok-4.6", | ||
| // --- Meta --- | ||
| "muse-spark-1.3-contributor", | ||
| "muse-spark-1.2-contributor", | ||
| ]) | ||
|
|
||
| export const OPENCODE_GO_RESPONSES_FORMAT_REGEX: RegExp[] = [ | ||
| // gpt-5.6 and above are routed by pattern for automatic discovery | ||
| /^gpt-(?:5\.(?:[6-9]|\d{2,})|[6-9]\d*(?:[.-]|$)|\d{2,}(?:[.-]|$))/i, | ||
|
Check warning on line 730 in packages/types/src/providers/opencode-go.ts
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This regex infers the API protocol from the GPT version, but Go documents endpoints per model—not a general rule for all future GPT generations. It also accepts malformed IDs such as gpt-5.6o and gpt-00. For this fix, I’d keep explicit Responses routing for GPT 5.6 Luna and GPT 6 Luna, and handle future-model discovery separately once there is a documented gateway contract |
||
| ] | ||
|
|
||
| /** | ||
| * Returns `true` when the given Go-plan model ID must be requested via the | ||
| * Anthropic Messages format (`/v1/messages`) rather than the OpenAI-compatible | ||
|
|
@@ -732,7 +747,10 @@ | |
| * format, matching the gateway's default routing. | ||
| */ | ||
| export function isOpencodeGoResponsesFormatModel(modelId: string): boolean { | ||
| return OPENCODE_GO_RESPONSES_FORMAT_MODELS.has(modelId) | ||
| return ( | ||
| OPENCODE_GO_RESPONSES_FORMAT_MODELS.has(modelId) || | ||
| OPENCODE_GO_RESPONSES_FORMAT_REGEX.some((regex) => regex.test(modelId)) | ||
|
Check warning on line 752 in packages/types/src/providers/opencode-go.ts
|
||
| ) | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| import { z } from "zod" | ||
|
|
||
| import type { ModelInfo } from "@roo-code/types" | ||
| import { opencodeGoDefaultModelInfo, getOpencodeGoModelInfo } from "@roo-code/types" | ||
| import { getOpencodeGoModelInfo, isOpencodeGoResponsesFormatModel, opencodeGoDefaultModelInfo } from "@roo-code/types" | ||
|
|
||
| import { throwIfAborted } from "../utils/abort-signal" | ||
|
|
||
|
|
@@ -32,6 +32,19 @@ | |
| data: z.array(opencodeGoModelSchema), | ||
| }) | ||
|
|
||
| // Capability defaults for uncurated Responses-format models. This lets newly | ||
| // discovered GPT models route and expose their output-token control without | ||
| // inventing model-specific pricing; prices remain available only for curated IDs. | ||
| const opencodeGoResponsesModelDefaults: ModelInfo = { | ||
|
Check warning on line 38 in src/api/providers/fetchers/opencode-go.ts
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new However, OpenCodeGo supports many different models, and some of them may not support reasoning effort, images, or other capabilities. Could we reduce the number of default properties, or avoid using defaults here altogether? |
||
| maxTokens: 128_000, | ||
| contextWindow: 1_050_000, | ||
| supportsImages: true, | ||
|
Check warning on line 41 in src/api/providers/fetchers/opencode-go.ts
|
||
| supportsPromptCache: true, | ||
|
Check warning on line 42 in src/api/providers/fetchers/opencode-go.ts
|
||
| supportsMaxTokens: true, | ||
|
Check warning on line 43 in src/api/providers/fetchers/opencode-go.ts
|
||
| supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"], | ||
| reasoningEffort: "medium", | ||
| } | ||
|
|
||
| /** | ||
| * Maps a raw Opencode Go model entry to the internal {@link ModelInfo} shape. | ||
| * | ||
|
|
@@ -47,8 +60,8 @@ | |
| * is curated, including its capabilities and pricing. | ||
| * 2. Override static limits and image support with live `/models` values when | ||
| * present, keeping the gateway authoritative for volatile fields. | ||
| * 3. Fall back to {@link opencodeGoDefaultModelInfo} for an unknown model, | ||
| * ensuring downstream consumers always receive a fully-populated object. | ||
| * 3. Use Responses-specific capability defaults for uncurated Responses | ||
| * models; otherwise use {@link opencodeGoDefaultModelInfo} for unknowns. | ||
| * | ||
| * @param model - Validated model entry from the `/models` response. | ||
| * @returns Normalised model metadata suitable for the model picker. | ||
|
|
@@ -71,6 +84,16 @@ | |
| } | ||
| } | ||
|
|
||
| if (isOpencodeGoResponsesFormatModel(model.id)) { | ||
| return { | ||
| ...opencodeGoResponsesModelDefaults, | ||
| ...(liveContextWindow !== undefined && { contextWindow: liveContextWindow }), | ||
| ...(liveMaxTokens !== undefined && { maxTokens: liveMaxTokens }), | ||
| ...(liveSupportsImages !== undefined && { supportsImages: liveSupportsImages }), | ||
| description: model.description ?? model.name, | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| maxTokens: liveMaxTokens ?? opencodeGoDefaultModelInfo.maxTokens, | ||
| contextWindow: liveContextWindow ?? opencodeGoDefaultModelInfo.contextWindow, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.