Repository navigation
Description
Summary
On a Linux VPS, opencode run (V2, v2.1.4 and v2.0.32) hangs during initialization: no session is created, stdout stays empty, and no error is emitted. The same hang occurs with a clean HOME (no config, no credentials) using a free model. Direct calls to the provider API from the same host succeed, so the provider and network egress are functional.
This looks related to the V1 report in #38723 (hang before session creation; established connection to the model registry held open).
Environment
- opencode version: 2.1.4 (also reproduced on 2.0.32)
- OS: Ubuntu 24.04.4 LTS, Linux 6.8 x86_64 (VPS, direct outbound access, no proxy)
- Terminal: none — non-interactive SSH (
TERMunset),ssh host 'opencode run …' - Shell:
/bin/bash(server default) - Install/channel:
curl -fsSL https://opencode.ai/v2/install | bash(latest channel) - Active plugins: none. Config contains one remote MCP server; the bug also reproduces with no user config at all
Reproduction
-
On a clean account/home (no
~/.config/opencode, no credentials):mkdir -p /tmp/oc-repro && cd /tmp/oc-repro HOME=/tmp/oc-clean timeout 90 opencode run --auto \ -m opencode/deepseek-v4.1-flash-free "Reply with exactly: OK" echo "exit=$?"
-
The process stays alive with zero stdout; it exits only via the external
timeout(exit=124). -
With a configured instance (provider key + a remote MCP server), the same command hangs the same way; the server log stops after location/MCP initialization and never reaches session creation.
Expected Behavior
The run creates a session, performs the model request, and prints the model's answer (OK). Direct API calls from the same machine complete in ~2 seconds.
Actual Behavior
-
No output, no error, no session; only an external timeout ends it.
-
Server log tail during the hang (DEBUG level):
message="location services booted" directory=/tmp/oc-repro message="mcp connected" server=… tools=4 message="Sent HTTP response" http.method=GET http.url=/api/event http.status=200 <nothing further> -
While hung, the managed service holds ESTABLISHED connections to the model registry / provider endpoints, e.g.:
ESTAB 185.x.x.x:39522 -> 8.6.112.5:443 (models.opencode.ai / api.opencode.ai) ESTAB 185.x.x.x:51566 -> 172.65.90.22:443 (opencode.ai) -
curl https://api.models.devfrom the host fails (connection error,http_code=000), whilehttps://models.dev,https://models.opencode.ai/api.jsonandhttps://opencode.aiare reachable.
Additional Context
-
Direct provider check from the same host (no opencode involved):
POST https://opencode.ai/inference/go/openai/v1/chat/completions (stream:true) -> HTTP 200, first chunk in ~2.6s -
Note: the gateway requires an
x-opencode-sessionheader; without it the API answers400 MissingSessionID, with it the completion succeeds. This suggests the CLI stalls before/while sending the session-scoped request. -
Read-only commands (
--version,models,auth list) respond instantly, including whilerunhangs. -
Worked exactly once immediately after a fresh install (free model returned
OK), then every subsequent attempt hung — consistent with the intermittent behaviour described inopencode runintermittently hangs during init — no session created, no output, no error (~56% failure rate observed) #38723. -
Tried without change: v2.0.32 vs v2.1.4, clean
HOME(fresh DB/config), explicitopencode serve --port …+--serverwithOPENCODE_PASSWORD(server responds over HTTP),OPENCODE_DISABLE_AUTOUPDATE=1,OPENCODE_DISABLE_MODELS_FETCH=1,OPENCODE_DISABLE_FILEWATCHER=1, multiple models (free and paid). -
No secrets or private addresses included in this report.
Activity
opencode-agent commentedon Oct 26, 2026
Thanks for the detailed report. I could reproduce this on 2.1.4, and it still happens on the latest
dev(5bf3e82).When stdin is not a terminal,
opencode runwaits for stdin to close before it creates a session, even when the prompt is given as an argument.ssh host 'opencode run …'(without-n) gives the remote command a stdin pipe that never closes, so the run waits forever with no output and no error. That matches what you saw.With a clean
HOME:opencode run --auto -m <model> "Reply with exactly: OK" </dev/nullgets past this point straight away. In my test it reaches the model lookup and fails at once, because I used a model that doesn't exist.(sleep 60) | timeout 20 opencode run --auto -m <model> "…"prints nothing and is only stopped bytimeout(exit 124).The script below reproduces it.
Until this is fixed,
ssh -n host 'opencode run …'or appending</dev/nullto the command should avoid the hang. If either one still hangs for you, please tell us. That would point to a second cause, such as the model registry connections you saw.Related: #38723 is the v1 report of the same symptom; its comments trace it to the same stdin read.
Reproduction script (repro.sh)
Run it:
bash repro.shDeepSeek runs: stdin from /dev/null, the cause of the OpenCode startu…
freshen(opencode-ci-harness): before v2.2.6 run waits for stdin to cl…