Skip to content

Commit 03462de

Browse files
refactor: stop uipath_cli tool from creating workspace directories
The runtime (deepagents' filesystem backend / Workspace.create) already owns workspace creation, so the tool's mkdir calls were redundant. Remove the workspace-root and subdir mkdir; the tool now only consumes the directory the caller provisions. Keeps the binary allowlist, destructive-command denylist, and subdir traversal guard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7f60d5d commit 03462de

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

src/uipath_langchain/agent/tools/internal_tools/uipath_cli_tool.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,12 @@ class UiPathCliArgs(BaseModel):
8484

8585

8686
def _resolve_run_dir(workspace_path: Path, subdir: str) -> Path | str:
87-
"""Resolve ``subdir`` under the workspace (creating it), or an ERROR string if it escapes."""
87+
"""Resolve ``subdir`` under the workspace"""
8888
if not subdir:
8989
return workspace_path
9090
candidate = (workspace_path / subdir).resolve()
9191
if not candidate.is_relative_to(workspace_path):
9292
return f"ERROR: subdir '{subdir}' escapes the workspace directory."
93-
candidate.mkdir(parents=True, exist_ok=True)
9493
return candidate
9594

9695

@@ -184,13 +183,8 @@ def create_uipath_cli_tool(
184183
timeout_sec: int = 120,
185184
denied_subcommands: Iterable[str] | None = None,
186185
) -> BaseTool:
187-
"""Build a ``uipath_cli`` tool jailed to ``workspace`` for advanced agents with skills.
188-
189-
The tool runs CLI commands with ``cwd`` under ``workspace.path``. The workspace
190-
lifecycle (creation, cleanup) stays owned by the runtime.
191-
"""
186+
"""Build a ``uipath_cli`` tool jailed to ``workspace`` for advanced agents with skills."""
192187
workspace_path = Path(workspace.path).expanduser().resolve()
193-
workspace_path.mkdir(parents=True, exist_ok=True)
194188
denied = frozenset(
195189
s.lower()
196190
for s in (

tests/agent/tools/internal_tools/test_uipath_cli_tool.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ def _invoke(tool: Any, **kwargs: Any) -> str:
2020

2121

2222
class TestCreateUipathCliTool:
23-
def test_creates_workspace_when_absent(self, tmp_path: Path) -> None:
23+
def test_does_not_create_workspace(self, tmp_path: Path) -> None:
24+
# The runtime owns workspace creation; the tool must not create directories.
2425
target = tmp_path / "does" / "not" / "exist"
2526
create_uipath_cli_tool(_workspace(target))
26-
assert target.is_dir()
27+
assert not target.exists()
2728

2829
def test_marks_tool_as_internal(self, tmp_path: Path) -> None:
2930
tool = create_uipath_cli_tool(_workspace(tmp_path))

0 commit comments

Comments
 (0)