fix(settings): match GLM reasoning choices to the model contract

This commit is contained in:
Bingxi Zhao (Frank)
2026-10-04 14:37:31 +08:00
parent 6a734e356c
commit 6327c41d55
2 changed files with 21 additions and 6 deletions

View File

@@ -150,6 +150,15 @@ function tableReasoningEffortOptions(
: options([], current);
}
if (
(OPENAI_PROVIDERS.has(provider) || provider === "custom" || provider === "zhipu") &&
(modelName === "glm-5.3" || modelName.endsWith("/glm-5.3"))
) {
// GLM-5.3 always thinks; older GLM families have different controls.
// https://docs.bigmodel.cn/cn/guide/models/text/glm-5.3
return options(["low", "high", "max"], current);
}
if (provider === "custom") {
// A user-supplied OpenAI-compatible endpoint may route to any upstream
// model, so expose the common cross-gateway levels and let Auto handle
@@ -204,12 +213,6 @@ function tableReasoningEffortOptions(
if (includesAny(modelName, ["o1", "o3", "o4"])) {
return options(["low", "medium", "high"], current);
}
if (includesAny(modelName, ["glm"])) {
// Zhipu GLM (open.bigmodel.cn coding endpoint) accepts the four levels;
// `none` means "omit the parameter", which for GLM turns server-side
// thinking fully on, so it stays off the menu.
return options(["minimal", "low", "medium", "high"], current);
}
return options([], current);
}

View File

@@ -192,3 +192,15 @@ test("Auto removes the catalog field instead of persisting an empty string", ()
setModelReasoningEffort(model, " medium ");
assert.equal(model.reasoning_effort, "medium");
});
test("GLM effort choices follow the documented model family and retain invalid values for recovery", () => {
assert.deepEqual(values("openai", "glm-5.3"), ["", "low", "high", "max"]);
assert.deepEqual(values("zhipu", "glm-5.3"), ["", "low", "high", "max"]);
assert.deepEqual(values("custom", "z-ai/glm-5.3"), ["", "low", "high", "max"]);
assert.deepEqual(values("azure", "GLM-5.3"), ["", "low", "high", "max"]);
assert.deepEqual(values("openai", "glm-4.7"), []);
assert.deepEqual(values("openai", "glm-5.3-unknown"), []);
assert.deepEqual(values("openai", "glm-5.3", "medium"), ["", "low", "high", "max", "medium"]);
assert.deepEqual(values("openai", "glm-4.7", "vendor-level"), ["", "vendor-level"]);
});