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
<think> in its template, so the thinking_forced_open logic, preserved
tokens, and grammar prefix were dead paths.
This commit is contained in:
Jesse Posner 2026-02-15 22:25:12 -08:00
parent ac0f256df0
commit bdc1dda64f
No known key found for this signature in database
GPG Key ID: 322C1E6648EF0F22
3 changed files with 1 additions and 14 deletions

View File

@ -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 ? "( \"</think>\" 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))

View File

@ -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 <think>)
if (string_ends_with(data.prompt, "<think>\n")) {
if (!params.enable_thinking) {
data.prompt += "</think>";
} else {
data.thinking_forced_open = true;
}
}
data.preserved_tokens = {
"<think>",
"</think>",
"<tool_call>",
"</tool_call>",
"<function=",

View File

@ -3566,14 +3566,13 @@ Hey there!<|im_end|>
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");
}
}
}