Skip to content

OpenCode hangs indefinitely when using Ollama behind reverse proxy (streaming SSE not delivered) #39357

Description

@bgoniasa

Description

opencode run hangs indefinitely when using a custom Ollama provider behind a reverse proxy (Easypanel/Traefik). The model responds correctly via non-streaming requests, but OpenCode uses streaming by default and never receives the SSE chunks.

Environment

  • OpenCode: v1.18.7
  • OS: Linux (Docker container)
  • Model: qwen2.5-coder:7b via Ollama (remote, behind Easypanel reverse proxy)
  • Provider config: @ai-sdk/openai-compatible with custom baseURL

Config

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama Remote",
      "options": {
        "baseURL": "https://<host>/v1"
      },
      "models": {
        "qwen2.5-coder:7b": {
          "name": "Qwen 2.5 Coder 7B"
        }
      }
    }
  },
  "model": "ollama/qwen2.5-coder:7b"
}

What works

Non-streaming requests work perfectly:

curl -s https://<host>/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"qwen2.5-coder:7b","messages":[{"role":"user","content":"say OK"}]}'
# Returns: {"choices":[{"message":{"content":"OK"}}]} OK

What doesn't work

Streaming requests return empty response through the reverse proxy:

curl -sN https://<host>/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"qwen2.5-coder:7b","stream":true,"messages":[{"role":"user","content":"say OK"}]}'
# Returns: (empty)

OpenCode logs show it starts streaming but never receives any data:

level=INFO message=stream providerID=ollama modelID=qwen2.5-coder:7b small=false agent=build
level=INFO message="llm runtime selected" llm.runtime=ai-sdk llm.provider=ollama llm.model=qwen2.5-coder:7b
# ... hangs here indefinitely

Root cause

The reverse proxy (Easypanel, which uses Traefik) appears to buffer or not properly forward SSE chunks. This is a common issue with reverse proxies and Ollama deployments.

Feature request

Add a config option to disable streaming for a provider, or auto-fallback to non-streaming when streaming data isn't received within a timeout. This would make OpenCode compatible with Ollama deployments behind reverse proxies that don't handle SSE correctly.

Something like:

"options": {
  "baseURL": "https://<host>/v1",
  "stream": false
}

Workaround

None found. OpenCode is unusable with this Ollama setup.

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