Restore Kimi tool calling and enforce strict thinking behavior#5722
Restore Kimi tool calling and enforce strict thinking behavior#5722Neonsy wants to merge 3 commits intoKilo-Org:mainfrom
Conversation
|
Who in the (insert confusion here) I'm pretty sure when I made the PR to add Kimi K2.5, image was turned true. Why is it false now... I love it when code gets changed without oversight 🙂
|
🦋 Changeset detectedLatest commit: 78dbcfa The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
I would love feedback and testing As stated in the PR body, Kimi K2.5 thinking is confirmed with the coding plan endpoint (kimi for coding should work the same), but IDK about the "normal" API endpoints. |
|
Thank you for your dedication, we really need Kilo's support for Kimi K2.5, I'm glad you've rekindled your spirit. Meanwhile, I hope to get help from @MoonshotAl official @RealKai42 |
@CaiDingxian I wouldn't say it's rekindled (or needed to be), I just knew I could help fast enough and didn't want to let everyone who is still suffering down. It's just that my priority has changed to trying to create a desktop experience, powered by Kilo with the same foundational spirit as the extension. |
|
Tested this with the Moonshot API Provider ( |
I need someone to test the classic API's (either one is fine) Don't have a key for that. |
|
"classic API's" means |
Yes Testing one of them should be enough. |
0600435 to
197f2f8
Compare
|
Rebuilt the extension with your most recent changes.
( Date/time: 2026-02-07T00:52:36.837Z Provider ended the request: No output generated. Check the stream for errors. Date/time: 2026-02-07T00:52:36.839Z No output generated. Check the stream for errors. |
This is a normal performance, kimi-for-coding only supports coding endpoint. |
I will make it so you can't select it with the other endpoints. The get API key button now changes URL for the coding endpoint. |
d1044cd to
191b0aa
Compare
|
I have tested the Kimi-K2.5 model from api.moonshot.cn using this pr code in my actual project, and it performed excellently with good stability. k2.5(thinking mode) even solved problems that GPT-5.3-Codex couldn't handle, which I find impressive. |
…tract - restore native tool metadata for kimi-k2.5 and kimi-for-coding - map AI SDK tool-input-* streams into executable tool_call chunks - enforce strict Kimi thinking behavior (thinking=1.0, non-thinking=0.6) and send moonshot thinking options - preserve assistant reasoning_content in AI-SDK message conversion - add regression tests for moonshot provider, ai-sdk transform, model params, and ThinkingBudget UI
191b0aa to
78dbcfa
Compare

Here we go again
I would appreciate proper validation this time around 😄
Context
This PR fixes the Moonshot/Kimi regression in #5719.
After the AI-SDK migration, users on Moonshot (
kimi-k2.5andkimi-for-coding) could hit a tool-calling loop withMODEL_NO_TOOLS_USED. In practice, Kilo would often output literal<read_file>-style text instead of executing native tool calls.We made this fix to re-align our Moonshot/Kimi behavior with Moonshot API expectations and restore reliable native tool execution, without rolling back the migration or changing behavior for unrelated providers.
Root causes addressed:
kimi-k2.5metadata no longer clearly advertised native tool support.tool-input-*events, but we did not always convert those into executabletool_callchunks.reasoning_content) needed to be preserved across AI-SDK message conversion.Why we did not do a Moonshot-only adapter fix
We considered patching only
MoonshotHandler, but the primary break happened in the shared AI-SDK/OpenAI-compatible stream layer (tool-input-*handling), not only in Moonshot-specific policy code.A Moonshot-only patch would have:
Instead, this PR:
MoonshotHandler.This keeps architecture clean, reduces duplication, and lowers long-term merge/regression risk.
Implementation
1) Restore strict Kimi model capabilities
Updated
packages/types/src/providers/moonshot.tsforkimi-k2.5andkimi-for-coding:supportsNativeTools: true,defaultToolProtocol: "native")preserveReasoning: true)supportsTemperature: false,defaultTemperature: 0.6)Why: ensure runtime and UI choose the correct native tool protocol and strict model behavior.
2) Convert Moonshot
tool-input-*streams into executable tool callsIn
src/api/providers/openai-compatible.ts:tool-input-start+tool-input-deltatool_callchunk ontool-input-endtool-callis also presentWhy: Moonshot may stream tool input incrementally; Task execution requires finalized
tool_callchunks.3) Enforce strict Kimi thinking contract in Moonshot handler
In
src/api/providers/moonshot.ts, for strict Kimi models only:enableReasoningEffort !== false) => forcetemperature = 1.0temperature = 0.6modelTemperaturefor these modelsenabled/disabled)Why: keep requests compliant with strict Kimi expectations and avoid invalid mixed settings.
4) Preserve reasoning continuity in AI-SDK conversion
In
src/api/transform/ai-sdk.ts:providerOptions.openaiCompatible.reasoning_contentWhy: avoid reasoning context loss across turns in the OpenAI-compatible path.
5) UI alignment for binary reasoning models
In
webview-ui/src/components/settings/ThinkingBudget.tsx:enableReasoningEffort ?? true)Why: UI default now matches backend behavior for strict Kimi models.
6) Regression coverage
Added/updated tests:
src/api/providers/__tests__/moonshot.spec.tssrc/api/transform/__tests__/ai-sdk.spec.tssrc/api/transform/__tests__/model-params.spec.tswebview-ui/src/components/settings/__tests__/ThinkingBudget.spec.tsxAdded changeset:
.changeset/green-geese-warn.mdScreenshots
How to Test
cd src && pnpm test api/providers/__tests__/moonshot.spec.ts api/transform/__tests__/ai-sdk.spec.ts api/transform/__tests__/model-params.spec.tscd webview-ui && pnpm test src/components/settings/__tests__/ThinkingBudget.spec.tsxmoonshothttps://api.kimi.com/coding/v1kimi-k2.5MODEL_NO_TOOLS_USEDkimi-for-coding1.0and Moonshot thinkingenabled0.6and Moonshot thinkingdisabledCaution
This PR relied heavily on AI assistance. I had already investigated this area in a previous PR attempt and used AI to accelerate implementation while keeping scope tight.