Skip to content

The agent that grows with you

fix(tools): search_files treats a JSON-null path like a blank one

teknium1ba96e68d475b
diff --git a/tests/tools/test_search_files_engine_selection.py b/tests/tools/test_search_files_engine_selection.py
index f548dece001..6cdb5e3616d 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"])
[email protected]("blank_path", ["", " \t "])
[email protected]("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 1e504d02389..4b312b63e75 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,