The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tools): normalize blank search paths
KoNit-K66cc3f165d2f
diff --git a/tests/tools/test_search_files_engine_selection.py b/tests/tools/test_search_files_engine_selection.pyindex 72e9100f847..f548dece001 100644--- a/tests/tools/test_search_files_engine_selection.py+++ b/tests/tools/test_search_files_engine_selection.py@@ -8,6 +8,7 @@ import pytestfrom tools.environments.local import LocalEnvironmentfrom tools.file_operations import SearchResult, ShellFileOperationsfrom tools.file_tools import SEARCH_FILES_SCHEMA, _handle_search_files, search_tool+from tools.registry import registryclass RecordingEnvironment:@@ -286,6 +287,37 @@ def test_handler_forwards_modified_order(monkeypatch):assert captured["order"] == "modified"[email protected]("target", ["content", "files"])[email protected]("blank_path", ["", " \t "])+def test_handler_normalizes_blank_path_to_current_directory(monkeypatch, target, blank_path):+ captured = {}++ def fake_search_tool(**kwargs):+ captured.update(kwargs)+ return "{}"++ monkeypatch.setattr("tools.file_tools.search_tool", fake_search_tool)++ registry.dispatch("search_files", {"pattern": "needle", "target": target, "path": blank_path})++ assert captured["target"] == target+ assert captured["path"] == "."+++def test_handler_preserves_nonblank_path(monkeypatch):+ captured = {}++ def fake_search_tool(**kwargs):+ captured.update(kwargs)+ return "{}"++ monkeypatch.setattr("tools.file_tools.search_tool", fake_search_tool)++ registry.dispatch("search_files", {"pattern": "needle", "path": "src"})++ assert captured["path"] == "src"++def test_repeated_search_key_distinguishes_order(monkeypatch):class StubOperations:def search(self, **kwargs):diff --git a/tools/file_tools.py b/tools/file_tools.pyindex ce8d1d4f7b9..1e504d02389 100644--- a/tools/file_tools.py+++ b/tools/file_tools.py@@ -1291,8 +1291,11 @@ 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)+ path = args.get("path", ".")+ if isinstance(path, str) and not path.strip():+ path = "."return search_tool(- pattern=args.get("pattern", ""), target=target, path=args.get("path", "."),+ pattern=args.get("pattern", ""), target=target, path=path,file_glob=args.get("file_glob"), limit=args.get("limit", 50), offset=args.get("offset", 0),output_mode=args.get("output_mode", "content"), context=args.get("context", 0),order=args.get("order", "discovery"), task_id=tid)