Skip to content

Commit 05a6869

Browse files
committed
Add qwen3_next to tool call format inference
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 9a8e3a5 commit 05a6869

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Libraries/MLXLMCommon/Tool/ToolCallFormat.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ public enum ToolCallFormat: String, Sendable, Codable, CaseIterable {
155155
return .xmlFunction
156156
}
157157

158+
// Qwen3-Next family (qwen3_next, etc.)
159+
if type.hasPrefix("qwen3_next") {
160+
return .xmlFunction
161+
}
162+
158163
// Mistral3 family (mistral3, mistral3_text, etc.)
159164
if type.hasPrefix("mistral3") {
160165
return .mistral

Tests/MLXLMTests/ToolTests.swift

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

550+
// Qwen3-Next models (prefix matching)
551+
#expect(ToolCallFormat.infer(from: "qwen3_next") == .xmlFunction)
552+
#expect(ToolCallFormat.infer(from: "qwen3_next_moe") == .xmlFunction)
553+
#expect(ToolCallFormat.infer(from: "QWEN3_NEXT") == .xmlFunction)
554+
550555
// Mistral3 models (prefix matching)
551556
#expect(ToolCallFormat.infer(from: "mistral3") == .mistral)
552557
#expect(ToolCallFormat.infer(from: "Mistral3") == .mistral)

0 commit comments

Comments
 (0)