The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tools): tool_call bridge treats blank arguments as no arguments
teknium1462c1c14dde0
diff --git a/tests/tools/test_tool_search.py b/tests/tools/test_tool_search.pyindex cd77ed81496..e44da62f149 100644--- a/tests/tools/test_tool_search.py+++ b/tests/tools/test_tool_search.py@@ -471,6 +471,17 @@ class TestBridgeDispatch:assert err is not Noneassert "bridge tool" in err.lower()+ @pytest.mark.parametrize("raw_args", ["", " \n", None])+ def test_resolve_underlying_call_treats_blank_arguments_as_no_arguments(self, raw_args):+ """An OpenAI-compatible gateway emitting ``arguments: ""`` for a parameterless deferred tool+ must execute with {} instead of looping on a JSON parse error (#83937); malformed+ non-blank arguments still fail closed."""+ from tools.tool_search import resolve_underlying_call+ name, args, err = resolve_underlying_call({"calls": [{"name": "todo_list", "arguments": raw_args}]})+ assert (name, args, err) == ("todo_list", {}, None)+ _, _, err = resolve_underlying_call({"calls": [{"name": "todo_list", "arguments": '{"todos": ['}]})+ assert err and "not valid JSON" in err+# ---------------------------------------------------------------------------# End-to-end via the real handle_function_call (smoke test).diff --git a/tools/tool_search_validation.py b/tools/tool_search_validation.pyindex a0cc28c67d3..fb62f879772 100644--- a/tools/tool_search_validation.py+++ b/tools/tool_search_validation.py@@ -173,7 +173,11 @@ def normalize_tool_call_entries(args: Dict[str, Any]) -> Tuple[List[Dict[str, Anif name in BRIDGE_TOOL_NAMES:return [], f"tool_call cannot invoke '{name}' (it is itself a bridge tool)"raw_args = raw.get("arguments")- if raw_args is None:+ if raw_args is None or (isinstance(raw_args, str) and not raw_args.strip()):+ # "" / whitespace is how some OpenAI-compatible gateways spell "no arguments" for a+ # parameterless tool (#83937); the loop already treats an empty outer arguments string+ # as {} (turn_tool_validation), and a missing required param still surfaces below via+ # validate_deferred_call_args instead of an opaque JSON parse error.raw_args = {}if isinstance(raw_args, str):try: