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..d0b7fd935 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,9 @@ def _parse_uip_command(command: str) -> list[str]: f"Shell operator '{token}' is not allowed; run one command at a time." ) + if tokens[:2] in (["codedagent", "run"], ["function", "run"]): + raise ValueError(f"`uip {' '.join(tokens[:2])}` is 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 -----------------------