diff --git a/nanobot/agent/tools/shell.py b/nanobot/agent/tools/shell.py index 3412a11a7..0252b9746 100644 --- a/nanobot/agent/tools/shell.py +++ b/nanobot/agent/tools/shell.py @@ -266,6 +266,7 @@ class ExecTool(Tool): # the raw command string to COMSPEC without re-quoting. return await asyncio.create_subprocess_shell( command, + stdin=asyncio.subprocess.DEVNULL, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, cwd=cwd, @@ -274,6 +275,7 @@ class ExecTool(Tool): bash = shutil.which("bash") or "/bin/bash" return await asyncio.create_subprocess_exec( bash, "-l", "-c", command, + stdin=asyncio.subprocess.DEVNULL, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, cwd=cwd, diff --git a/tests/tools/test_exec_platform.py b/tests/tools/test_exec_platform.py index 301df4a7a..69a271ec1 100644 --- a/tests/tools/test_exec_platform.py +++ b/tests/tools/test_exec_platform.py @@ -5,6 +5,7 @@ strategy, and sandbox behaviour per platform — without actually running platform-specific binaries (all subprocess calls are mocked). """ +import asyncio import sys from unittest.mock import AsyncMock, patch @@ -108,6 +109,9 @@ class TestSpawnUnix: assert "-c" in args assert "echo hi" in args + kwargs = mock_exec.call_args[1] + assert kwargs["stdin"] == asyncio.subprocess.DEVNULL + class TestSpawnWindows: @@ -124,6 +128,9 @@ class TestSpawnWindows: args = mock_shell.call_args[0] assert "dir" in args + kwargs = mock_shell.call_args[1] + assert kwargs["stdin"] == asyncio.subprocess.DEVNULL + @pytest.mark.asyncio async def test_passes_cwd_and_env(self): env = {"PATH": "/usr/bin"}