From 549739a9b7e09fca46fd1d12c7d8c2edbc5d85c5 Mon Sep 17 00:00:00 2001 From: Ke Jin Date: Tue, 11 Aug 2026 19:55:41 +0800 Subject: [PATCH] fix(kimi): apply K3 effort policy to aliases (#10005) --- .../providers/registry/kimi/coding/runtime.ts | 4 +++- tests/unit/responses-handler.test.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/open-sse/config/providers/registry/kimi/coding/runtime.ts b/open-sse/config/providers/registry/kimi/coding/runtime.ts index aedd32fc1d..dfd469658e 100644 --- a/open-sse/config/providers/registry/kimi/coding/runtime.ts +++ b/open-sse/config/providers/registry/kimi/coding/runtime.ts @@ -25,7 +25,9 @@ const KIMI_CODE_STATIC_THINKING_POLICIES: Record export function getKimiCodeStaticThinkingPolicy(modelId: unknown): KimiCodeThinkingPolicy | null { if (typeof modelId !== "string") return null; - return KIMI_CODE_STATIC_THINKING_POLICIES[modelId] || null; + const normalizedModel = modelId.trim().toLowerCase().split("/").pop() || ""; + if (/^k3(?:$|-)/.test(normalizedModel)) return KIMI_CODE_STATIC_THINKING_POLICIES.k3; + return KIMI_CODE_STATIC_THINKING_POLICIES[normalizedModel] || null; } export type KimiCodeDeviceIdentity = { diff --git a/tests/unit/responses-handler.test.ts b/tests/unit/responses-handler.test.ts index a22542f29f..0ec6adf448 100644 --- a/tests/unit/responses-handler.test.ts +++ b/tests/unit/responses-handler.test.ts @@ -263,6 +263,22 @@ test("handleResponsesCore preserves Kimi K3 reasoning through provider translati assert.equal(native.call.body.messages?.[1]?.reasoning_content, "I should search first."); }); +test("handleResponsesCore maps unsupported Kimi K3 xhigh effort to max", async () => { + const { call, result } = await invokeResponsesCore({ + body: { + model: "k3-256k", + reasoning: { effort: "xhigh", summary: "auto" }, + input: "Reply with OK.", + }, + provider: "kimi-coding-apikey", + model: "k3-256k", + }); + + assert.equal(result.success, true); + assert.deepEqual(call.body.thinking, { type: "enabled" }); + assert.deepEqual(call.body.output_config, { effort: "max" }); +}); + test("handleResponsesCore strips previous_response_id by default and handles empty input arrays", async () => { const { call, result } = await invokeResponsesCore({ body: {