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
This commit is contained in:
Leo Zhang 2026-04-24 23:37:29 +08:00 committed by GitHub
parent ea94afe777
commit cb58a561f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -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|>";