feat(opencode-go): muse-spark-1.2 and Responses tool fixes (#3820)
- Add muse-spark-1.2-contributor as responses-only model on OpenCode Go - Normalize object tool schemas without properties in OpenCode Go executor - Make fallback Responses call_ids unique across same-millisecond calls - Make Responses output coercion fail-soft for circular and non-stringifiable values
This commit is contained in:
@@ -61,9 +61,12 @@ function normalizeResponsesTools(body) {
|
||||
const name = rawName.trim();
|
||||
if (!name) return false;
|
||||
const description = typeof tool.description === "string" ? tool.description : (typeof fn?.description === "string" ? fn.description : "");
|
||||
const parameters = (tool.parameters && typeof tool.parameters === "object" && !Array.isArray(tool.parameters))
|
||||
let parameters = (tool.parameters && typeof tool.parameters === "object" && !Array.isArray(tool.parameters))
|
||||
? tool.parameters
|
||||
: (fn?.parameters && typeof fn.parameters === "object" && !Array.isArray(fn.parameters) ? fn.parameters : { type: "object", properties: {} });
|
||||
// Mirror the request translator: {type:"object"} without properties is rejected
|
||||
// by strict Responses backends, so fill in the empty properties map.
|
||||
if (parameters.type === "object" && !parameters.properties) parameters = { ...parameters, properties: {} };
|
||||
for (const k of Object.keys(tool)) delete tool[k];
|
||||
tool.type = "function";
|
||||
tool.name = name.slice(0, MAX_TOOL_NAME_LEN);
|
||||
|
||||
@@ -52,6 +52,7 @@ export default {
|
||||
{ id: "qwen3.6-plus", name: "Qwen 3.6 Plus", supportedFormats: ["openai", "claude"] },
|
||||
// Muse Spark is served by /zen/go/v1/responses only — responses-only entry forces
|
||||
// chatCore past the sourceFormat-matched transports into translation (see chatCore guard).
|
||||
{ id: "muse-spark-1.2-contributor", name: "Muse Spark 1.2 Contributor", targetFormat: "openai-responses", supportedFormats: ["openai-responses"] },
|
||||
{ id: "muse-spark-1.3-contributor", name: "Muse Spark 1.3 Contributor", targetFormat: "openai-responses", supportedFormats: ["openai-responses"] },
|
||||
],
|
||||
features: {
|
||||
|
||||
@@ -26,8 +26,13 @@ export function normalizeResponsesInput(input) {
|
||||
// Strict Responses upstreams reject overlong call_ids with InputValidationError (#393).
|
||||
export const MAX_RESPONSES_CALL_ID_LEN = 64;
|
||||
|
||||
// Fallback ids share one Date.now() when a batch of items is sanitized in a tight
|
||||
// loop — a per-process sequence keeps same-millisecond ids unique so
|
||||
// function_call ↔ function_call_output correlation never collides.
|
||||
let responsesCallIdSeq = 0;
|
||||
|
||||
export function clampResponsesCallId(id) {
|
||||
if (typeof id !== "string" || !id) return `call_${Date.now()}`;
|
||||
if (typeof id !== "string" || !id) return `call_${Date.now()}_${(responsesCallIdSeq += 1)}`;
|
||||
return id.length > MAX_RESPONSES_CALL_ID_LEN ? id.substring(0, MAX_RESPONSES_CALL_ID_LEN) : id;
|
||||
}
|
||||
|
||||
@@ -55,7 +60,15 @@ export function coerceResponsesArguments(value) {
|
||||
export function coerceResponsesOutput(value) {
|
||||
if (typeof value === "string") return value;
|
||||
if (value === undefined || value === null) return "";
|
||||
if (Array.isArray(value)) return value.map((c) => c?.text ?? JSON.stringify(c)).join("");
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((c) => {
|
||||
try {
|
||||
return c?.text ?? JSON.stringify(c);
|
||||
} catch {
|
||||
return String(c);
|
||||
}
|
||||
}).join("");
|
||||
}
|
||||
try {
|
||||
return JSON.stringify(value);
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user