Build and run agents you can see, understand and trust.
Python agentchatbotlarge-language-modelsllmllm-agentmcpmulti-agentmulti-modalreact-agentrealtime-agentvoice-agentvoice-assistant
fix(tool): support windows-style separators in glob patterns (#1809)
Muhammad Faisal Ishfaq9a0ce739844b
diff --git a/src/agentscope/tool/_builtin/_glob.py b/src/agentscope/tool/_builtin/_glob.pyindex cf7531d30..5ea038de3 100644--- a/src/agentscope/tool/_builtin/_glob.py+++ b/src/agentscope/tool/_builtin/_glob.py@@ -259,7 +259,7 @@ codebase.""" # ignore: E501A list of matched file paths"""results: list[str] = []- parts = pattern.split("/")+ parts = [p for p in re.split(r"[\\/]+", pattern) if p]self.match_parts(parts, 0, base_dir, results)return resultsdiff --git a/tests/builtin_glob_test.py b/tests/builtin_glob_test.pyindex eb9fe563d..8a5d109a8 100644--- a/tests/builtin_glob_test.py+++ b/tests/builtin_glob_test.py@@ -11,6 +11,8 @@ from agentscope.permission import (PermissionRule,)+from tests.utils import AnyString+class GlobToolTest(IsolatedAsyncioTestCase):"""The glob tool test case."""@@ -101,6 +103,34 @@ class GlobToolTest(IsolatedAsyncioTestCase):self.assertIn("test2.py", content)self.assertIn("test3.py", content)+ async def test_windows_style_separator_pattern(self) -> None:+ """Test glob patterns that use backslashes as path separators."""+ chunk = await self.glob_tool(+ pattern=r"subdir\*.py",+ path=self.temp_dir,+ )++ self.assertDictEqual(+ chunk.model_dump(),+ {+ "content": [+ {+ "type": "text",+ "text": os.path.join(+ self.temp_dir,+ "subdir",+ "test3.py",+ ),+ "id": AnyString(),+ },+ ],+ "state": "running",+ "is_last": True,+ "metadata": {},+ "id": AnyString(),+ },+ )+async def test_no_matches(self) -> None:"""Test pattern with no matches."""chunk = await self.glob_tool(