Skip to content

Commit b331db1

Browse files
authored
Add qwen3_next to tool call format inference (#166)
The Qwen3-Next family uses the same XML tool call format as Qwen3.5 but wasn't recognized by ToolCallFormat.infer(), so tool calls were silently lost. Fixes #161.
1 parent 81fba5e commit b331db1

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Libraries/MLXLMCommon/Tool/ToolCallFormat.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ public enum ToolCallFormat: String, Sendable, Codable, CaseIterable {
185185
return .xmlFunction
186186
}
187187

188+
// Qwen3-Next family (qwen3_next, etc.)
189+
if type.hasPrefix("qwen3_next") {
190+
return .xmlFunction
191+
}
192+
188193
// Mistral3 family (mistral3, mistral3_text, etc.)
189194
if type.hasPrefix("mistral3") {
190195
return .mistral

Tests/MLXLMTests/ToolTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,11 @@ struct ToolTests {
641641
#expect(ToolCallFormat.infer(from: "qwen3_5_moe") == .xmlFunction)
642642
#expect(ToolCallFormat.infer(from: "QWEN3_5") == .xmlFunction)
643643

644+
// Qwen3-Next models (prefix matching)
645+
#expect(ToolCallFormat.infer(from: "qwen3_next") == .xmlFunction)
646+
#expect(ToolCallFormat.infer(from: "qwen3_next_moe") == .xmlFunction)
647+
#expect(ToolCallFormat.infer(from: "QWEN3_NEXT") == .xmlFunction)
648+
644649
// Mistral3 models (prefix matching)
645650
#expect(ToolCallFormat.infer(from: "mistral3") == .mistral)
646651
#expect(ToolCallFormat.infer(from: "Mistral3") == .mistral)

0 commit comments

Comments
 (0)