fix(opencode): normalize Muse Free tool choice

OpenCode Free returns HTTP 400 for muse-spark-1.3-contributor-free when tool_choice is non-auto. Declare forceAutoToolChoiceModels quirk and normalize explicit tool_choice to auto.
This commit is contained in:
KunN-21
2026-09-17 18:19:38 +07:00
parent eafac37dcb
commit aa14ef72e2
3 changed files with 98 additions and 0 deletions

View File

@@ -411,6 +411,11 @@ export class OpenCodeExecutor extends BaseExecutor {
transformRequest(model, body, stream, credentials) {
if (body && typeof body === "object" && model && !body.model) body.model = model;
if (isResponsesModel(model || body?.model) && body && typeof body === "object") {
// ponytail: chỉ model đã xác nhận auto-only; mở allowlist khi có bằng chứng.
if ("tool_choice" in body && body.tool_choice !== "auto"
&& this.config.quirks?.forceAutoToolChoiceModels?.includes(baseModelId(model))) {
body.tool_choice = "auto";
}
const normalized = normalizeResponsesInput(body.input);
if (normalized) body.input = normalized;
if (!Array.isArray(body.input) || body.input.length === 0) {