-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Description
When the LLM generates a command that triggers a [sudo] password for <user> prompt, the subprocess hangs indefinitely waiting for password input that can never arrive. OI uses subprocess.Popen with stdin=subprocess.PIPE — there is no terminal for password entry. The process blocks until the execution timeout fires (default 120s), with no indication of what went wrong.
Steps to reproduce
- Start OI with
auto_run = True(or approve when prompted) - Ask it to do something that requires root, e.g. "check the systemd journal for errors"
- The LLM generates
sudo journalctl -xe - OI hangs for ~120 seconds with no output
- Eventually times out with a generic error
Root cause
handle_stream_output() in subprocess_language.py reads lines via iter(stream.readline, "") and checks for KeyboardInterrupt, active line markers, and end-of-execution markers — but has no detection for sudo password prompts. The [sudo] password for message arrives on stderr, gets queued as regular output, and the process continues blocking on stdin.
Suggested fix
Detect the sudo prompt pattern in the output stream and immediately signal completion with a clear message:
def handle_stream_output(self, stream, is_error_stream):
try:
for line in iter(stream.readline, ""):
...
line = self.line_postprocessor(line)
if line is None:
continue
+ if "[sudo] password for" in line:
+ self.output_queue.put(
+ {
+ "type": "console",
+ "format": "output",
+ "content": "[sudo detected — command requires elevated "
+ "privileges. Run it manually.]\n",
+ }
+ )
+ self.done.set()
+ return
if self.detect_active_line(line):
...Since the subprocess uses pipes (not a PTY), we cannot send Ctrl+C to cancel the sudo prompt. But self.done.set() causes run() to stop waiting and return. The blocked subprocess is cleaned up when terminate() is called on the next execution or OI exit.
Environment
- open-interpreter 0.4.3
- Python 3.10, Linux (ARM64)
- Ollama backend, bash shell execution