fix(tool-parser): preserve "none"/"nil" strings as valid enum values in minimax_m2 (#39599)

Signed-off-by: Yiyang Liu <yiyangliu@microsoft.com>
Signed-off-by: Yiyang Liu <37043548+ianliuy@users.noreply.github.com>
Signed-off-by: sfeng33 <4florafeng@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: sfeng33 <4florafeng@gmail.com>
Co-authored-by: Roger Wang <hey@rogerw.io>
This commit is contained in:
Yiyang "Ian" Liu
2026-05-13 20:35:34 -04:00
committed by GitHub
co-authored by Copilot sfeng33 Roger Wang
parent ca7e4546da
commit 63cc8a55a9
2 changed files with 137 additions and 6 deletions
+7 -6
View File
@@ -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: