diff --git a/tests/tool_parsers/test_minimax_m2_tool_parser.py b/tests/tool_parsers/test_minimax_m2_tool_parser.py
index 98a2fb8a2d..963c3462ff 100644
--- a/tests/tool_parsers/test_minimax_m2_tool_parser.py
+++ b/tests/tool_parsers/test_minimax_m2_tool_parser.py
@@ -548,3 +548,133 @@ class TestAnyOfNullableParam:
parsed = json.loads(tc[0]["arguments"])
assert parsed["config"] == {"theme": "dark", "fontSize": 14}
assert isinstance(parsed["config"], dict)
+
+
+class TestNoneStringPreservation:
+ """Regression tests for #39567: 'none' as a string must not become None."""
+
+ def test_none_string_preserved_in_enum(self):
+ """'none' in an enum must stay as the string 'none', not Python None."""
+ tools = [
+ ChatCompletionToolsParam(
+ function=FunctionDefinition(
+ name="set_theme",
+ parameters={
+ "type": "object",
+ "properties": {
+ "theme": {
+ "type": "string",
+ "enum": ["dark", "light", "none"],
+ },
+ },
+ },
+ ),
+ )
+ ]
+ parser = MinimaxM2ToolParser(FakeTokenizer(), tools=tools)
+
+ results = _feed(
+ parser,
+ [
+ ''
+ 'none'
+ "",
+ ],
+ )
+ tc = _collect_tool_calls(results)
+ assert len(tc) == 1
+ parsed = json.loads(tc[0]["arguments"])
+ assert parsed["theme"] == "none"
+ assert parsed["theme"] is not None
+
+ def test_none_string_preserved_plain_string(self):
+ """'none' as a plain string param must stay as 'none'."""
+ tools = [
+ ChatCompletionToolsParam(
+ function=FunctionDefinition(
+ name="echo",
+ parameters={
+ "type": "object",
+ "properties": {
+ "message": {"type": "string"},
+ },
+ },
+ ),
+ )
+ ]
+ parser = MinimaxM2ToolParser(FakeTokenizer(), tools=tools)
+
+ results = _feed(
+ parser,
+ [
+ ''
+ 'none'
+ "",
+ ],
+ )
+ tc = _collect_tool_calls(results)
+ assert len(tc) == 1
+ parsed = json.loads(tc[0]["arguments"])
+ assert parsed["message"] == "none"
+
+ def test_null_still_converts_to_none(self):
+ """'null' in a nullable param must still become Python None."""
+ tools = [
+ ChatCompletionToolsParam(
+ function=FunctionDefinition(
+ name="update_profile",
+ parameters={
+ "type": "object",
+ "properties": {
+ "nickname": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ },
+ },
+ ),
+ )
+ ]
+ parser = MinimaxM2ToolParser(FakeTokenizer(), tools=tools)
+
+ results = _feed(
+ parser,
+ [
+ ''
+ 'null'
+ "",
+ ],
+ )
+ tc = _collect_tool_calls(results)
+ assert len(tc) == 1
+ parsed = json.loads(tc[0]["arguments"])
+ assert parsed["nickname"] is None
+
+ def test_nil_string_preserved(self):
+ """'nil' must stay as the string 'nil', not become None."""
+ tools = [
+ ChatCompletionToolsParam(
+ function=FunctionDefinition(
+ name="echo",
+ parameters={
+ "type": "object",
+ "properties": {
+ "value": {"type": "string"},
+ },
+ },
+ ),
+ )
+ ]
+ parser = MinimaxM2ToolParser(FakeTokenizer(), tools=tools)
+
+ results = _feed(
+ parser,
+ [
+ ''
+ 'nil'
+ "",
+ ],
+ )
+ tc = _collect_tool_calls(results)
+ assert len(tc) == 1
+ parsed = json.loads(tc[0]["arguments"])
+ assert parsed["value"] == "nil"
diff --git a/vllm/tool_parsers/minimax_m2_tool_parser.py b/vllm/tool_parsers/minimax_m2_tool_parser.py
index 028468fe51..85fb266b95 100644
--- a/vllm/tool_parsers/minimax_m2_tool_parser.py
+++ b/vllm/tool_parsers/minimax_m2_tool_parser.py
@@ -160,16 +160,13 @@ class MinimaxM2ToolParser(ToolParser):
Returns:
The converted value
"""
- # Check if the VALUE itself indicates null (not just if null is allowed)
- if value.lower() in ("null", "none", "nil"):
- return None
-
# Normalize types
normalized_types = [t.lower() for t in param_types]
# Try each type in order of preference (most specific first, string as fallback)
- # Priority: integer > number > boolean > object > array > string
+ # Priority: null > integer > number > boolean > object > array > string
type_priority = [
+ "null",
"integer",
"int",
"number",
@@ -187,7 +184,11 @@ class MinimaxM2ToolParser(ToolParser):
if param_type not in normalized_types:
continue
- if param_type in ["string", "str", "text"]:
+ if param_type == "null":
+ if value.lower() == "null":
+ return None
+ continue
+ elif param_type in ["string", "str", "text"]:
return value
elif param_type in ["integer", "int"]:
try: