Skip to content

[FEATURE]: let opencode run ignore an unused inherited stdin pipe #42064

Description

@vladislav-miroshnikov
  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

opencode run reads non-TTY stdin to EOF before starting a prompt. That is the right default for intentional input such as:

cat context.txt | opencode run "review this"

The problem is that some supervisors give every child a pipe and keep its writer open, even when the command has no stdin payload. The prompt then never starts. This minimal Python control retains the pipe deliberately; changing PIPE to DEVNULL makes the same command progress to the expected invalid-model error:

import subprocess

args = ["opencode", "run", "--model", "invalid/provider-model", "reply with OK"]

def run(stdin):
    child = subprocess.Popen(args, stdin=stdin)
    try:
        return f"exit {child.wait(timeout=5)}"
    except subprocess.TimeoutExpired:
        child.terminate()
        child.wait()
        return "still waiting after 5s"

print("open pipe:", run(subprocess.PIPE))
print("closed input:", run(subprocess.DEVNULL))

Could run expose an explicit opt-out, for example --no-stdin? It would skip only the stdin read for that invocation; the existing default and pipe + positional prompt behavior would not change. I have a small implementation and subprocess tests ready if this interface is acceptable.

The symptom also appeared in #11891, which documented DEVNULL as a caller-side workaround. Related #25508 and merged #16300 show why silently ignoring piped input is not safe. When the caller controls descriptors, DEVNULL, stdin: "ignore", or closing the writer remains the workaround.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions