Skip to content

LLM inference in C/C++

C++ ggml

chat : force `\n</think>` on reasoning budget end for qwen3-coder (#28869)

Aldehir Rojas0bec16e3880a
diff --git a/common/parsers/qwen3-coder.cpp b/common/parsers/qwen3-coder.cpp
index 7938a20279..208f551f1b 100644
--- a/common/parsers/qwen3-coder.cpp
+++ b/common/parsers/qwen3-coder.cpp
@@ -23,8 +23,9 @@ common_chat_params common_chat_params_init_qwen3_coder(const common_chat_templat
if (supports_reasoning) {
data.thinking_start_tag = "<think>";
// Support both </think> and <tool_call> as reasoning end sequences.
+ // The newline variant comes first so it is included in the forced message
// <function= is omitted, as it is a workaround for Qwen3-Coder which is not a thinking model
- data.thinking_end_tags = { "</think>", "<tool_call>" };
+ data.thinking_end_tags = { "\n</think>", "</think>", "<tool_call>" };
data.preserved_tokens.insert(data.preserved_tokens.end(), { "<think>", "</think>" });
}