


























@@ -307,6 +307,126 @@ describe("kimi tool-call markup wrapper", () => {
307307});
308308});
309309310+it("backfills Kimi OpenAI-compatible tool-call reasoning_content when thinking is enabled", () => {
311+const { streamFn: baseStreamFn, getCapturedPayload } = createPayloadCapturingStream({
312+messages: [
313+{ role: "user", content: "run pwd" },
314+{
315+role: "assistant",
316+content: null,
317+tool_calls: [
318+{
319+id: "call_1",
320+type: "function",
321+function: { name: "exec", arguments: "{\"command\":\"pwd\"}" },
322+},
323+],
324+},
325+{
326+role: "assistant",
327+content: "kept",
328+reasoning_content: "native reasoning",
329+tool_calls: [
330+{
331+id: "call_2",
332+type: "function",
333+function: { name: "read", arguments: "{}" },
334+},
335+],
336+},
337+],
338+});
339+340+const wrapped = createKimiThinkingWrapper(baseStreamFn, "enabled");
341+void wrapped(
342+{
343+api: "openai-completions",
344+provider: "kimi",
345+id: "kimi-for-coding",
346+} as Model<"openai-completions">,
347+{ messages: [] } as Context,
348+{},
349+);
350+351+expect(getCapturedPayload()).toEqual({
352+messages: [
353+{ role: "user", content: "run pwd" },
354+{
355+role: "assistant",
356+content: null,
357+reasoning_content: "",
358+tool_calls: [
359+{
360+id: "call_1",
361+type: "function",
362+function: { name: "exec", arguments: "{\"command\":\"pwd\"}" },
363+},
364+],
365+},
366+{
367+role: "assistant",
368+content: "kept",
369+reasoning_content: "native reasoning",
370+tool_calls: [
371+{
372+id: "call_2",
373+type: "function",
374+function: { name: "read", arguments: "{}" },
375+},
376+],
377+},
378+],
379+thinking: { type: "enabled" },
380+});
381+});
382+383+it("strips Kimi OpenAI-compatible replay reasoning_content when thinking is disabled", () => {
384+const { streamFn: baseStreamFn, getCapturedPayload } = createPayloadCapturingStream({
385+messages: [
386+{
387+role: "assistant",
388+content: null,
389+reasoning_content: "old reasoning",
390+tool_calls: [
391+{
392+id: "call_1",
393+type: "function",
394+function: { name: "exec", arguments: "{\"command\":\"pwd\"}" },
395+},
396+],
397+},
398+],
399+});
400+401+const wrapped = createKimiThinkingWrapper(baseStreamFn, "disabled");
402+void wrapped(
403+{
404+api: "openai-completions",
405+provider: "kimi",
406+id: "kimi-for-coding",
407+} as Model<"openai-completions">,
408+{ messages: [] } as Context,
409+{},
410+);
411+412+expect(getCapturedPayload()).toEqual({
413+messages: [
414+{
415+role: "assistant",
416+content: null,
417+tool_calls: [
418+{
419+id: "call_1",
420+type: "function",
421+function: { name: "exec", arguments: "{\"command\":\"pwd\"}" },
422+},
423+],
424+},
425+],
426+thinking: { type: "disabled" },
427+});
428+});
429+310430it("enables Kimi Anthropic thinking with a high budget and enough output room", () => {
311431const { streamFn: baseStreamFn, getCapturedPayload } = createPayloadCapturingStream();
312432此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。