From 90e53b3f22539c3e718893ec2a2e0cd6ba5dce56 Mon Sep 17 00:00:00 2001 From: Paul Zhu Date: Wed, 8 Jul 2026 00:48:46 -0700 Subject: [PATCH] fix(sdk): enable thinking mode on the llama.cpp VLM path Gemma-4 ships an mmproj file so it loads as a VLM and runs through vlm.cpp, which hardcoded enable_thinking=false and dropped special tokens in token_to_piece. Pass enable_thinking through and render special tokens so reasoning channel delimiters reach the caller. Closes qcom-ai-hub/geniex#1208 Signed-off-by: Paul Zhu --- sdk/plugins/llama_cpp/src/vlm.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sdk/plugins/llama_cpp/src/vlm.cpp b/sdk/plugins/llama_cpp/src/vlm.cpp index 330ef6e55..54a2ebe6d 100644 --- a/sdk/plugins/llama_cpp/src/vlm.cpp +++ b/sdk/plugins/llama_cpp/src/vlm.cpp @@ -154,10 +154,7 @@ int32_t LlamaVlm::apply_chat_template( tmpl_inputs.tools = common_chat_tools_parse_oaicompat(nlohmann::ordered_json::parse(std::string(input->tools))); } - if (input->enable_thinking) { - GENIEX_LOG_WARN("thinking mode not supported for llama.cpp VLM; ignoring enable_thinking=true"); - } - tmpl_inputs.enable_thinking = false; + tmpl_inputs.enable_thinking = input->enable_thinking; GENIEX_LOG_DEBUG("applying chat template with add_generation_prompt=true, use_jinja={}", tmpl_inputs.use_jinja); // Apply chat template @@ -399,7 +396,7 @@ int32_t LlamaVlm::generate(const geniex_VlmGenerateInput* input, geniex_VlmGener break; } - int n = llama_token_to_piece(vocab, token, token_buffer, sizeof(token_buffer) - 1, 0, false); + int n = llama_token_to_piece(vocab, token, token_buffer, sizeof(token_buffer) - 1, 0, true); if (n < 0) n = 0; token_buffer[n] = '\0';