fix(core): fail closed on empty tool arguments (#4545)

This commit is contained in:
Henry Su
2026-08-20 15:55:29 -05:00
committed by GitHub
parent f73e747530
commit 1b7eb28f25
3 changed files with 5 additions and 1 deletions
+3 -1
View File
@@ -17,9 +17,11 @@ def _reject_nonstandard_json_constant(value: str) -> NoReturn:
def parse_function_tool_arguments(arguments: str | None) -> dict[str, Any] | None:
"""Return parsed object arguments, or None when an approval policy cannot inspect them."""
if arguments is None or not arguments.strip():
return None
try:
parsed = json.loads(
arguments or "{}",
arguments,
parse_constant=_reject_nonstandard_json_constant,
)
except ValueError:
+1
View File
@@ -3125,6 +3125,7 @@ class TestToolCallExecution:
@pytest.mark.parametrize(
"arguments",
[
"",
'{"subject": "refund"',
"null",
"[]",
+1
View File
@@ -919,6 +919,7 @@ async def test_function_needs_approval_invalid_type_raises() -> None:
@pytest.mark.parametrize(
"arguments",
[
"",
'{"subject": "refund"',
"null",
"[]",