From ceb851ad76a1388295d808ac764e94eb79c14b93 Mon Sep 17 00:00:00 2001 From: Maria Dhakal Date: Tue, 22 Sep 2026 13:47:37 -0700 Subject: [PATCH] feat(agent): block uip codedagent run and function run in uipath_cli tool --- .../agent/tools/internal_tools/uipath_cli_tool.py | 4 ++++ tests/agent/tools/internal_tools/test_uipath_cli_tool.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/uipath_langchain/agent/tools/internal_tools/uipath_cli_tool.py b/src/uipath_langchain/agent/tools/internal_tools/uipath_cli_tool.py index 85cd0b5d0..765c514ea 100644 --- a/src/uipath_langchain/agent/tools/internal_tools/uipath_cli_tool.py +++ b/src/uipath_langchain/agent/tools/internal_tools/uipath_cli_tool.py @@ -88,6 +88,10 @@ def _parse_uip_command(command: str) -> list[str]: f"Shell operator '{token}' is not allowed; run one command at a time." ) + words = [t.lower() for t in tokens if not t.startswith("-")] + if "run" in words and {"codedagent", "function", "functions"} & set(words): + raise ValueError("`uip codedagent run` and `uip function run` are blocked.") + return tokens diff --git a/tests/agent/tools/internal_tools/test_uipath_cli_tool.py b/tests/agent/tools/internal_tools/test_uipath_cli_tool.py index 7387fec93..ba32b7dcb 100644 --- a/tests/agent/tools/internal_tools/test_uipath_cli_tool.py +++ b/tests/agent/tools/internal_tools/test_uipath_cli_tool.py @@ -55,6 +55,12 @@ def test_parse_rejects_shell_operators(command: str) -> None: _parse_uip_command(command) +@pytest.mark.parametrize("command", ["codedagent run", "function run"]) +def test_parse_blocks_local_run_commands(command: str) -> None: + with pytest.raises(ValueError, match="blocked"): + _parse_uip_command(command) + + # --- command examples stay aligned with the real CLI -----------------------