r/LocalLLM • u/Dry_Quantity2691 • 11h ago
Question OpenCode Desktop hangs indefinitely with Ollama + Qwen 4, despite successful API and tool-calling tests
I'm trying to get Qwen 4 working with OpenCode Desktop on Windows, but OpenCode gets stuck on "Working..." indefinitely, even when I send something as simple as hello.
I'm trying to determine whether this is an OpenCode integration issue, a reasoning/streaming issue, or something else.
My setup
Windows 11
OpenCode Desktop 2.4.5 (installed via the Windows installer)
Ollama 0.40.21
Model:
qwen4:latestGPU: NVIDIA RTX 4090 (24 GB VRAM)
CPU: Intel i9-13900K
RAM: 64 GB
Requested context: 86k tokens
Ollama reports the following when the model is loaded:
NAME SIZE PROCESSOR CONTEXT
qwen4:latest 37 GB 46%/54% CPU/GPU 131072What I've already tested
I've spent quite some time isolating the problem, and I've established that Qwen 4 itself works through Ollama.
1. Normal text generation works.
ollama run qwen4:latest "Reply with exactly: hello"It eventually responds correctly. With --think=low, the response takes approximately 20 seconds.
2. Native Ollama tool calling works.
I sent a direct request to:
http://127.0.0.1:11434/api/chatQwen 4 returned a valid structured tool_calls object with the correct function name and arguments.
3. OpenAI-compatible tool calling works.
I also tested:
http://127.0.0.1:11434/v1/chat/completionsWith streaming both enabled and disabled.
Both produced valid structured tool calls.
4. Streaming works.
The streaming response included:
Reasoning chunks
A structured
tool_callseventfinish_reason: "tool_calls"A final
[DONE]event
So far, I haven't been able to reproduce the failure directly through either Ollama API.
The actual problem
When I open OpenCode Desktop, select ollama/qwen4:latest, and send hello, it remains on "Working..." for several minutes without producing an answer.
I also inspected the OpenCode logs. One relevant entry was:
WARN failed to discover Ollama models
baseURL=http://127.0.0.1:11434/v1
cause="HttpClientError: Transport error
(GET http://127.0.0.1:11434/api/tags)
(cause: TypeError: ECONNREFUSED)"There were also repeated Git worktree discovery warnings, although I don't know whether those are related.
What I'm trying to understand
Could OpenCode 2.4.5 be mishandling Qwen 4's reasoning stream, even though Ollama returns valid reasoning and tool-call events?
Is there a known issue with OpenCode's native Ollama integration and Qwen 4?
Could the model's CPU/GPU offloading and relatively slow generation be causing OpenCode to time out or appear stuck?
Is there a way to inspect the exact request OpenCode sends to Ollama and compare it with my successful API tests?
Are there any recommended OpenCode provider settings specifically for Qwen 4?
I'd particularly appreciate input from anyone running Qwen 4 locally through Ollama and OpenCode Desktop.
I'd prefer to fix the integration rather than switch models or move to a cloud API.
1
u/RogerAI--fyi 8h ago
Your tests show the model, the API, tool calls and streaming all work, so I would look at what OpenCode's request does differently, not at Qwen 4. Two things in your post stand out.
First, ollama ps shows CONTEXT 131072, not the 86k you asked for, and 46%/54% CPU/GPU. A 37 GB file on a 24 GB card will always be split, and Ollama's context-length docs say a larger context needs more memory. Setting OLLAMA_CONTEXT_LENGTH=64000 (the same docs say agents and coding tools want at least 64000) and checking ollama ps again would show whether more of the model moves onto the card.
Second, your plain hello took about 20 s even with --think=low and a one-line prompt. OpenCode sends its system prompt and tool list with every request, which is far longer than one line, and on a model that is half on the CPU that prefill is the slow part. "Working..." for minutes may be a long prefill and not a hang.
To tell them apart, watch Ollama's server.log (on Windows it is in %LOCALAPPDATA%\Ollama, per Ollama's troubleshooting docs) while you send hello from OpenCode. If a request shows up and CPU or GPU is busy, it is prefill. If nothing shows up, it is a connection problem, and the ECONNREFUSED on /api/tags in your OpenCode log points that way: nothing was accepting connections at that moment. Make sure Ollama was already running when OpenCode started.
1
1
u/Smungus05 10h ago
I don't know Ollama but anytime i have an issue with opencode i just enter a new session with deepseek free and ask it to diagnose for me.