You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Streaming ECONNRESET / "socket connection was closed unexpectedly" with SGLang OpenAI-compatible provider during tool-using agent runs (Qwen3.5 + reasoning content) #22803
When using opencode with a self-hosted SGLang server serving Qwen3.5-27B-FP8 as a custom OpenAI-compatible provider, streaming chat completions fail intermittently during agent/build-mode runs with:
ECONNRESET on POST /v1/chat/completions
UI message: Cannot connect to API: The socket connection was closed unexpectedly. For more i...
Auto-retry loops indefinitely (Connection reset by server, retrying in 25s - attempt #21)
There is no nginx / reverse proxy / load balancer between opencode and SGLang — it is a direct TCP connection from the opencode sidecar to http://<host>:8000/v1/chat/completions.
Sidecar error logs
ERROR service=llm providerID=aifactory modelID=qwen3.5-27b-fp8
sessionID=... agent=build mode=primary
error={"error":{"code":"ECONNRESET","path":"http://<host>:8000/v1/chat/completions","errno":0}}
stream error
ERROR service=session.processor
error=The socket connection was closed unexpectedly.
For more information, pass `verbose: true` in the second argument to fetch()
Plugins
none
OpenCode version
1.4.3
Steps to reproduce
Start SGLang serving Qwen3.5-27B-FP8 with an OpenAI-compatible endpoint:
Configure opencode with a custom OpenAI-compatible provider pointing directly at http://<host>:8000 (no proxy in between), model id qwen3.5-27b-fp8.
Start a build-mode / agent session and give it a task that triggers tool use, e.g. "continue working on the frontend — explore the existing code structure first".
Observe:
First few tool rounds may succeed.
After 1–3 rounds the stream drops with ECONNRESET / "socket connection was closed unexpectedly".
opencode enters an infinite retry loop (Connection reset by server, retrying in 25s - attempt #21).
Workarounds we tried
Switching SGLang to --tool-call-parser qwen3 (instead of qwen3_coder) changes the parser routing and appears to reduce the frequency of drops, but the issue still occurs on longer agent runs.
Disabling reasoning entirely (either by removing --reasoning-parser qwen3 from SGLang, or by sending chat_template_kwargs: {"enable_thinking": false} in the request) makes the ECONNRESET go away — the stream completes cleanly every time.
However, this is not a real solution for our use case: without reasoning enabled, the model does not reliably plan or chain tool calls anymore, i.e. it is no longer agentic. Build-mode sessions become single-shot replies instead of multi-step tool-using runs, which defeats the purpose of using opencode with a reasoning model. So reasoning has to stay on, and the crash has to be fixed on the streaming-client side.
Screenshot and/or share link
Operating System
Server (SGLang host): Ubuntu 22.04, 2× NVIDIA GPUs, SGLang in a venv, launched via systemd - Client (opencode host): Windows 11
This issue might be a duplicate of (or closely related to) existing issues. Please check:
ECONNRESET with zai-coding-plan provider (api.z.ai) #15350: ECONNRESET with OpenAI-compatible provider — same error code, same Bun connection-pooling/keep-alive root-cause analysis, same symptom of the stream dropping after a number of seconds.
Activity
github-actions commentedon Apr 16, 2026
This issue might be a duplicate of (or closely related to) existing issues. Please check:
Klausmd5 commentedon Apr 16, 2026
having the same issue with OpenCode Desktop v1.4.6 also using Qwen3.5 via vllm
mwroffo commentedon Apr 17, 2026
Having this issue on 1.3.13 CLI with Claude 4.5 sonnet via bedrock.
github-actions commentedon Jul 5, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.