From ba96e68d475bbdbe698fbb806d0573ea69c3b104 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Wed, 16 Sep 2026 09:57:16 -0700 Subject: [PATCH] fix(tools): search_files treats a JSON-null path like a blank one The model can send `"path": null` as easily as `"path": ""`; on base a None path reached search_tool and surfaced as an os.PathLike TypeError instead of the documented current-directory default. Widen the blank-path normalisation in _handle_search_files to any non-string and pin it in the existing parametrized test. Co-authored-by: joaomarcos --- tests/tools/test_search_files_engine_selection.py | 3 ++- tools/file_tools.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/tools/test_search_files_engine_selection.py b/tests/tools/test_search_files_engine_selection.py index f548dece00..6cdb5e3616 100644 --- a/tests/tools/test_search_files_engine_selection.py +++ b/tests/tools/test_search_files_engine_selection.py @@ -288,8 +288,9 @@ def test_handler_forwards_modified_order(monkeypatch): @pytest.mark.parametrize("target", ["content", "files"]) -@pytest.mark.parametrize("blank_path", ["", " \t "]) +@pytest.mark.parametrize("blank_path", ["", " \t ", None]) def test_handler_normalizes_blank_path_to_current_directory(monkeypatch, target, blank_path): + """#112424: a present-but-blank (or null) path must fall back to the documented '.' default.""" captured = {} def fake_search_tool(**kwargs): diff --git a/tools/file_tools.py b/tools/file_tools.py index 1e504d0238..4b312b63e7 100644 --- a/tools/file_tools.py +++ b/tools/file_tools.py @@ -1291,8 +1291,10 @@ def _handle_search_files(args, **kw): target_map = {"grep": "content", "find": "files"} raw_target = args.get("target", "content") target = target_map.get(raw_target, raw_target) + # The schema documents path='.'; a present-but-blank (or JSON null) value + # is not a missing key for dict.get, so apply the default here (#112424). path = args.get("path", ".") - if isinstance(path, str) and not path.strip(): + if not isinstance(path, str) or not path.strip(): path = "." return search_tool( pattern=args.get("pattern", ""), target=target, path=path,