fix(opencode-go): route every responses-only model (incl. thinking variants) to /responses

Derive responses-only routing from the model registry's targetFormat instead of hardcoding model checks, and strip thinking suffixes when looking up models in providerModels so variants like gpt-5.6-luna(high) are routed correctly to /responses.
This commit is contained in:
Ridho Perdana
2026-09-17 17:59:45 +07:00
parent 912ed295db
commit 702b57c30d
4 changed files with 41 additions and 6 deletions

View File

@@ -1,7 +1,8 @@
import crypto from "node:crypto";
import { DefaultExecutor } from "./default.js";
import { resolveSessionId } from "../utils/sessionManager.js";
import { isMuseSparkModel } from "../providers/models/helpers.js";
import { modelTargetFormat } from "../providers/models/schema.js";
import { getProviderModels } from "../config/providerModels.js";
import {
normalizeResponsesInput,
clampResponsesCallId,
@@ -45,8 +46,11 @@ function baseModelId(model) {
return String(model || "").replace(/\([^()]+\)\s*$/, "").trim();
}
// Responses-only per the provider registry (grok-4.6, gpt-5.6-luna, muse-spark, …).
// Reading the registry keeps this in sync with config — never hardcode model ids here.
function isResponsesModel(model) {
return isMuseSparkModel(baseModelId(model));
const entry = getProviderModels("opencode-go").find((m) => m.id === baseModelId(model));
return modelTargetFormat(entry) === "openai-responses";
}
// Flatten Chat Completions tool declarations into the Responses flat shape and