Unverified Commit b075604d authored by 김의진's avatar 김의진 Committed by GitHub
Browse files

[Bugfix] Fix Gemma4 tool parser converting bare `null` to string `"null"` (#39679)


Signed-off-by: default avatarKimuGenie <baby11686@naver.com>
Signed-off-by: default avatarChauncey <chaunceyjiang@gmail.com>
Co-authored-by: default avatarChauncey <chaunceyjiang@gmail.com>
parent db8a6d66
......@@ -85,6 +85,14 @@ class TestParseGemma4Args:
result = _parse_gemma4_args("flag:false")
assert result == {"flag": False}
def test_null_value(self):
# Bare `null` must parse as None (Python), not the string "null".
# Without this, tool_choice=auto would emit `{"param": "null"}`
# instead of `{"param": null}` for nullable tool parameters.
result = _parse_gemma4_args("param:null")
assert result == {"param": None}
assert json.dumps(result) == '{"param": null}'
def test_mixed_types(self):
result = _parse_gemma4_args(
'name:<|"|>test<|"|>,count:42,active:true,score:3.14'
......
......@@ -66,6 +66,10 @@ def _parse_gemma4_value(value_str: str) -> object:
if value_str == "false":
return False
# Null
if value_str.lower() in ("null", "none", "nil"):
return None
# Number (int or float)
try:
if "." in value_str:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment