From cb58a561f0c49f68b6d125cdfda037ed80433821 Mon Sep 17 00:00:00 2001 From: Leo Zhang Date: Fri, 24 Apr 2026 23:37:29 +0800 Subject: [PATCH] fix: Kimi-K2 parser ignores enable_thinking=false, response goes to reasoning_content (#1686) When `enable_thinking` is false (e.g. via `chat_template_kwargs: {thinking: false}`), the Kimi-K2 parser was still extracting reasoning tokens and routing all output to `reasoning_content` instead of `content`. The fix aligns with how other thinking models (Qwen3, etc.) handle this: check both `reasoning_format != NONE` and `enable_thinking` before enabling reasoning extraction. Fixes #1685 --- common/chat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/chat.cpp b/common/chat.cpp index 8dc0161f..ed1c0e54 100644 --- a/common/chat.cpp +++ b/common/chat.cpp @@ -1356,7 +1356,7 @@ static common_chat_params common_chat_params_init_kimi_k2(const common_chat_temp }; auto has_tools = inputs.tools.is_array() && !inputs.tools.empty(); - auto extract_reasoning = inputs.reasoning_format != COMMON_REASONING_FORMAT_NONE; + auto extract_reasoning = inputs.reasoning_format != COMMON_REASONING_FORMAT_NONE && inputs.enable_thinking; auto include_grammar = has_tools && inputs.tool_choice != COMMON_CHAT_TOOL_CHOICE_NONE; const std::string SECTION_BEGIN = "<|tool_calls_section_begin|>";