Skip to content

Commit 5c9e80a

Browse files
committed
cli: fix enable_thinking and chat_template_kwargs not being used
PR ggml-org#18675 (Autoparser refactor) accidentally replaced `chat_params.enable_thinking` with a call to `common_chat_templates_support_enable_thinking()`, which only checks if the template supports thinking — ignoring --reasoning-budget and --chat-template-kwargs entirely. This restores the use of `chat_params.enable_thinking` (which already incorporates reasoning_budget), adds the missing chat_template_kwargs passthrough, and parses the enable_thinking kwarg to keep inputs.enable_thinking consistent with what the template receives (matching server-common.cpp behavior). Fixes ggml-org#20182
1 parent c96f608 commit 5c9e80a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tools/cli/cli.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,20 @@ struct cli_context {
193193
inputs.parallel_tool_calls = false;
194194
inputs.add_generation_prompt = true;
195195
inputs.reasoning_format = COMMON_REASONING_FORMAT_DEEPSEEK;
196-
inputs.enable_thinking = common_chat_templates_support_enable_thinking(chat_params.tmpls.get());
196+
inputs.enable_thinking = chat_params.enable_thinking;
197+
inputs.chat_template_kwargs = chat_params.chat_template_kwargs;
198+
199+
// sync enable_thinking with kwargs (mirrors server-common.cpp)
200+
{
201+
auto it = inputs.chat_template_kwargs.find("enable_thinking");
202+
if (it != inputs.chat_template_kwargs.end()) {
203+
if (it->second == "true") {
204+
inputs.enable_thinking = true;
205+
} else if (it->second == "false") {
206+
inputs.enable_thinking = false;
207+
}
208+
}
209+
}
197210

198211
// Apply chat template to the list of messages
199212
return common_chat_templates_apply(chat_params.tmpls.get(), inputs);

0 commit comments

Comments
 (0)