cli: opencode run hangs indefinitely with local Ollama model

Abierto
#65,367 6 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
38/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
nodejs, ollama, typescript
Área
cli

Línea de trabajo

Start by reproducing with opencode debug config to confirm the resolved default model, then run opencode run "Reply with exactly: LOCAL_OK" with a short timeout and check whether the request ever reaches http://127.0.0.1:11434/v1. The report leaves two suspects: the @ai-sdk/openai-compatible provider path and the sandbox block, since Docker Desktop's engine was not running during the hang while the remote-model control succeeded. Done means opencode run either prints the reply or exits with a clear timeout/connection error, ideally covered by a test that exercises a non-streaming local endpoint.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area/cli platform/windows type/bug version/v2

Summary

opencode run with the default local Ollama model produces no output and never exits. The same CLI completes normally with an HTTP-compatible remote model, and Ollama's own API answers the same prompt in seconds.

Environment

  • opencode version: 1.18.31 (opencode --version; executable resolved through %APPDATA%\npm\opencode.ps1). OpenCode Desktop 2.3.2 is also installed but its CLI is not the one on PATH.
  • OS: Microsoft Windows NT 10.0.26300.0 (Windows 11 x64). ver is unavailable in PowerShell, so [Environment]::OSVersion.VersionString was used.
  • Terminal: TERM=xterm-256color; TERM_PROGRAM, COLORTERM, and WT_SESSION unset. Command was launched from the OpenCode shell tool (non-interactive).
  • Shell: %COMSPEC% = C:\WINDOWS\system32\cmd.exe; OpenCode config sets "shell": "powershell" for its own shell tool.
  • Install/channel: npm global install, release channel (C:\Users\<user>\AppData\Roaming\npm\opencode.ps1).
  • Active plugins: None found. No plugins key in ~/.config/opencode/opencode.json or opencode.jsonc; no .opencode/plugin, .opencode/plugins, plugin, or plugins directories under the global config directory.

Reproduction

  1. Install Ollama 0.40.16 and pull qwen2.5-coder:7b (4.7 GB). Run ollama serve with OLLAMA_HOST=127.0.0.1:11434; confirm GET http://127.0.0.1:11434/api/tags returns 200.
  2. In the global config, the resolved default model is ollama/qwen2.5-coder:7b (opencode debug config confirms this).
  3. Run opencode run "Reply with exactly: LOCAL_OK" from any directory.
  4. Wait several minutes. No output is produced and the prompt never returns.
  5. Control A: direct POST http://127.0.0.1:11434/api/generate with {"model":"qwen2.5-coder:7b","prompt":"Say OK","stream":false,"options":{"num_predict":8}} returns HTTP 200, body {"response":"OK"}, in about 19 seconds.
  6. Control B: opencode run -m freellmapi/nemotron-3-ultra-550b "Reply with exactly: SAFE_OK" prints SAFE_OK and exits normally.

Expected Behavior

opencode run should print the model's reply and exit, or surface a clear timeout/connection error if the model cannot be reached.

Actual Behavior

The process stayed alive for about 8 minutes with no stdout and no error. Get-Process showed the opencode.exe process alive with Responding = True and roughly 22 seconds of cumulative CPU time. The parent shell also stayed alive with no output because the pipeline buffers until the child exits. Both were terminated manually; the shell reported exit code 4294967295.

Additional Context

  • Frequency: observed once; not re-run after restarting Ollama.
  • Ollama was listening only on 127.0.0.1:11434 with an inbound firewall block, so this is not a network reachability problem.
  • Relevant global config (no credentials shown):
"model": "ollama/qwen2.5-coder:7b",
"provider": {
  "ollama": {
    "npm": "@ai-sdk/openai-compatible",
    "options": { "baseURL": "http://127.0.0.1:11434/v1" },
    "models": {
      "qwen2.5-coder:7b": { "name": "Qwen2.5 Coder 7B" }
    }
  }
},
"sandbox": {
  "enabled": true,
  "image": "langchain/langgraph-sandbox:latest",
  "resources": { "cpu": 2, "memory": "4GiB" }
}
  • Docker Desktop's engine was not running during the failing test (it was started afterwards for an unrelated container audit). If sandbox startup is involved in this hang, that is worth checking; the remote-model control succeeded under the same condition.
  • No custom plugins or provider overrides affect this model beyond the config above.
Lenguaje dominante
TypeScript
Estrellas
227k
Forks
30.7k
Merge medio
3 h 57 min
PR fusionados (30 d)
484

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de anomalyco/opencode

Todos los issues de anomalyco/opencode

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.