mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
fix(kimi): normalize reasoning_effort to backend enum (#2427)
Map auto→high, minimal→low, xhigh→max and whitelist low/medium/high/max so Kimi/kimchi SGLang backends no longer receive invalid effort values. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Cursor
parent
97a6708651
commit
8c068a1f5c
@@ -132,6 +132,15 @@ function toGeminiThinkingLevel(cfg) {
|
||||
return effortToThinkingLevel(raw);
|
||||
}
|
||||
|
||||
function toKimiReasoningEffort(cfg) {
|
||||
const level = toLevel(cfg);
|
||||
if (level === "auto") return "high";
|
||||
if (level === "minimal") return "low";
|
||||
if (level === "xhigh") return "max";
|
||||
if (["low", "medium", "high", "max"].includes(level)) return level;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Gemini nests thinkingConfig under generationConfig. gemini-cli / antigravity wrap
|
||||
// the whole request in a { request: { generationConfig } } envelope — target the
|
||||
// envelope's generationConfig when present, else the top-level one.
|
||||
@@ -217,8 +226,8 @@ function applyFormat(fmt, body, cfg, caps) {
|
||||
}
|
||||
case "kimi": {
|
||||
if (none && canDisable) { body.thinking = { type: "disabled" }; break; }
|
||||
const level = toLevel(eff);
|
||||
if (level) body.reasoning_effort = level === "max" ? "high" : level;
|
||||
const effort = toKimiReasoningEffort(eff);
|
||||
if (effort) body.reasoning_effort = effort;
|
||||
break;
|
||||
}
|
||||
case "minimax": {
|
||||
|
||||
@@ -106,6 +106,16 @@ describe("applyThinking per provider format", () => {
|
||||
const out = apply("openai", "kimi-k2.6", { reasoning_effort: "high" }, "kimi");
|
||||
expect(out.reasoning_effort).toBe("high");
|
||||
});
|
||||
it("Kimi auto → supported reasoning_effort", () => {
|
||||
const out = apply("openai", "kimi-k2.7", { reasoning_effort: "auto" }, "kimchi");
|
||||
expect(out.reasoning_effort).toBe("high");
|
||||
});
|
||||
it("Kimi unsupported OpenAI levels → supported reasoning_effort", () => {
|
||||
const minimal = apply("openai", "kimi-k2.7", { reasoning_effort: "minimal" }, "kimchi");
|
||||
const xhigh = apply("openai", "kimi-k2.7", { reasoning_effort: "xhigh" }, "kimchi");
|
||||
expect(minimal.reasoning_effort).toBe("low");
|
||||
expect(xhigh.reasoning_effort).toBe("max");
|
||||
});
|
||||
it("MiniMax M3 → adaptive", () => {
|
||||
const out = apply("claude", "MiniMax-M3", { reasoning_effort: "high" }, "minimax");
|
||||
expect(out.thinking).toEqual({ type: "adaptive" });
|
||||
|
||||
Reference in New Issue
Block a user