From bdc1dda64f80393af9255128dcdf70ea08e3e046 Mon Sep 17 00:00:00 2001 From: Jesse Posner Date: Sun, 15 Feb 2026 22:25:12 -0800 Subject: [PATCH] chat : remove dead thinking code from qwen3_coder_xml Remove thinking handling code that became unreachable after routing Step-3.5-Flash to the Nemotron v3 PEG parser. Qwen3-Coder has no in its template, so the thinking_forced_open logic, preserved tokens, and grammar prefix were dead paths. --- common/chat-parser-xml-toolcall.cpp | 1 - common/chat.cpp | 11 ----------- tests/test-chat.cpp | 3 +-- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/common/chat-parser-xml-toolcall.cpp b/common/chat-parser-xml-toolcall.cpp index 56d8bb410a..a80900ff8d 100644 --- a/common/chat-parser-xml-toolcall.cpp +++ b/common/chat-parser-xml-toolcall.cpp @@ -279,7 +279,6 @@ void build_grammar_xml_tool_call(common_chat_params & data, const json & tools, auto call_end = builder.add_rule("root-call-end", form.last_tool_end ? gbnf_format_literal(*form.last_tool_end) : gbnf_format_literal(form.tool_end)); auto tool_call_multiple_with_end = builder.add_rule("root-tool-call-multiple-with-end", tool_call_once + " " + tool_call_more + "* " + call_end); builder.add_rule("root", - std::string(data.thinking_forced_open ? "( \"\" space )? " : "") + (form.scope_start.empty() ? "" : gbnf_format_literal(form.scope_start) + " ") + tool_call_multiple_with_end + "?" + (form.scope_end.empty() ? "" : " " + gbnf_format_literal(form.scope_end)) diff --git a/common/chat.cpp b/common/chat.cpp index d87cb682c5..04fe8bc070 100644 --- a/common/chat.cpp +++ b/common/chat.cpp @@ -1884,18 +1884,7 @@ static common_chat_params common_chat_params_init_qwen3_coder_xml(const common_c data.prompt = apply(tmpl, params); data.format = COMMON_CHAT_FORMAT_QWEN3_CODER_XML; - // Handle thinking tags (e.g. Step-3.5-Flash unconditionally emits ) - if (string_ends_with(data.prompt, "\n")) { - if (!params.enable_thinking) { - data.prompt += ""; - } else { - data.thinking_forced_open = true; - } - } - data.preserved_tokens = { - "", - "", "", "", " common_chat_templates_inputs inputs; inputs.messages = { message_user }; inputs.tools = { special_function_tool }; - inputs.enable_thinking = true; auto params = common_chat_templates_apply(tmpls.get(), inputs); assert_equals(COMMON_CHAT_FORMAT_PEG_CONSTRUCTED, params.format); assert_equals(true, params.thinking_forced_open); assert_equals(false, params.grammar.empty()); assert_equals(false, params.parser.empty()); auto grammar = build_grammar(params.grammar); - GGML_ASSERT(grammar && "Failed to build Step-3.5-Flash grammar with thinking_forced_open"); + GGML_ASSERT(grammar && "Failed to build Step-3.5-Flash grammar"); } } }