Skip to content

opencode run hangs indefinitely with no output when stdin is not at EOF (non-interactive usage broken) #52938

Closed as not planned

Description

@YIbaikaishui

Description

opencode run "<prompt>" hangs forever with no output unless stdin is already at EOF. In non-interactive/scripted usage this makes it unusable: you get no error, no timeout message, just a process that never exits.

Environment

  • opencode: 1.18.33
  • OS: Windows 11 24H2, Windows Terminal
  • invocation: opencode run --model glm/glm-5.3-flash "say hi"

Steps to reproduce

  1. opencode run --model glm/glm-5.3-flash "reply with the single word PUNG"
  2. Wait — it never prints anything and never exits.
  3. Killed at 120 s, 75 s, 75 s → three consecutive timeouts, exit=124, zero bytes of output.

Fix / workaround

Redirect stdin from a closed stream and it works immediately:

opencode run --model glm/glm-5.3-flash "say hi" < /dev/null

exit=0, correct reply in about a second on a freshly reset DB.

This is the whole difference — the flag surface is identical, only stdin differs. So the hang is not the request path (a model call would have produced partial output or an error); opencode is blocking waiting for interactive input before it ever starts the turn.

Why this matters

Anything scripted — cron, a Makefile, a shell pipeline, a wrapper script — will hit this. opencode run is documented as the non-interactive form, and as documented it is simply broken for a piped/empty stdin.

Related note

--permission allow is not a valid flag on 1.18.33; passing it prints the help text and exits 1. Worth documenting either way.

Activity

  1. github-actions commented on Oct 3, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. Starefossen commented on Oct 8, 2026

    @Starefossen

    Still the case in v2 (2.0.24, macOS). run.ts:76 reads stdin to EOF whenever stdin is not a TTY, even when a message argument is given. Fix: skip stdin when a message argument is given, unless - asks for it.

  3. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

  4. YIbaikaishui commented on Oct 26, 2026

    @YIbaikaishui
    Author

    Re-opening with evidence: this is still reproducible on OpenCode 2.0.24 (macOS) — @Starefossen confirmed on 2026-10-08 that run.ts:76 still reads stdin to EOF whenever stdin is not a TTY, even when a - message argument is provided. The "upgrade to 2.0" closure rationale does not hold for this specific bug.

    Minimal repro: an inherited open stdin pipe (e.g. piped input) combined with a - message argument causes opencode run to hang with no output, because stdin is read to EOF before the message is processed.

    Requested fix: skip the stdin read when a message argument is given, unless stdin is explicitly asked for. This keeps non-interactive usage (CI, agent pipelines) working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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