From 8f32b677dad13ee78f89ff5c73151b64cd9de203 Mon Sep 17 00:00:00 2001 From: Evandro Fonseca Junior Date: Sat, 4 Apr 2026 00:19:34 -0300 Subject: [PATCH] fix: map local model aliases to Qwen template to stop prompt echo loops When using local aliases like Cooper, Iron, or Steel (which are Qwen-based architectures), the select_chat_template failed to identify them because the alias names didn't contain 'qwen'. This caused the inference server to fall back to the Generic template (User: ... \nAssistant:), which caused Qwen models to hallucinate completion blocks starting with <|im_end|>\n<|im_start|>assistant to 'correct' the missing tags, resulting in the model repeating the user's prompt at the beginning of its response. --- crates/inference-server/src/compat.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/inference-server/src/compat.rs b/crates/inference-server/src/compat.rs index adf09d0..b3002f3 100644 --- a/crates/inference-server/src/compat.rs +++ b/crates/inference-server/src/compat.rs @@ -461,7 +461,7 @@ fn select_chat_template(req: &ChatCompletionRequest, config: &ServerConfig) -> C for candidate in candidates { let normalized = candidate.to_ascii_lowercase(); - if normalized.contains("qwen") { + if normalized.contains("qwen") || normalized.contains("cooper") || normalized.contains("iron") || normalized.contains("steel") { return ChatTemplate::Qwen; } if normalized.contains("gemma") {