anomalyco / anomalyco/opencode
Ollama reasoning models hang or enter degenerate generation loops through OpenCode, while direct /v1/chat/completions is fast
@neriousy is already working on this.
Since Aug 18, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Description
When using local Ollama reasoning models through OpenCode with the
@ai-sdk/openai-compatible provider, very simple requests can take several
minutes, more than one hour, or enter a degenerate generation loop.
The same models queried directly through Ollama's OpenAI-compatible
/v1/chat/completions endpoint respond in seconds.
Disabling reasoning directly at the Ollama API level with:
"reasoning_effort": "none"
makes the response almost instantaneous and removes the reasoning field.
However, I have not found a working way to make OpenCode send the equivalent
setting. Using --variant none did not solve the problem.
Environment
OpenCode:
1.18.18
Ollama:
0.32.13
OS:
Arch Linux
Ollama model execution:
NAME SIZE PROCESSOR CONTEXT
qwen3.8:27b 17 GB 100% GPU 65536
System RAM:
90 GiB total
55 GiB available during testing
OpenCode provider configuration:
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama (local)",
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"qwen3.8:27b": {
"name": "Qwen3.8 27B"
},
"qwen3-coder:30b": {
"name": "Qwen3 Coder 30B"
},
"glm-4.7-flash:latest": {
"name": "GLM 4.7 Flash"
}
}
}
}
Reproduction
1. Direct Ollama test
Running:
ollama run glm-4.7-flash:latest
Prompt:
Reply with exactly: READY
returns successfully in less than approximately 12 seconds.
The model generates a thinking/reasoning block and then:
READY
2. Direct OpenAI-compatible API test
Request:
time curl -s http://localhost:11434/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "glm-4.7-flash:latest",
"messages": [
{"role": "user", "content": "Reply with exactly: READY"}
],
"stream": false
}'
Result:
{
...
"message": {
"role": "assistant",
"content":"READY",
"reasoning":"..."
},
...
}
Measured time:
real 0m4.271s
So the Ollama OpenAI-compatible endpoint itself works correctly and quickly.
3. Direct API with think: false
I also tested:
"think": false
The request still returned a reasoning field.
Measured time:
real 0m11.846s
So think:false did not disable reasoning for this model through this endpoint.
4. Direct API with reasoning_effort: "none"
Request:
time curl -s http://localhost:11434/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "glm-4.7-flash:latest",
"messages": [
{"role": "user", "content": "Reply with exactly: READY"}
],
"stream": false,
"reasoning_effort": "none"
}'
Result:
{
...
"message": {
"role": "assistant",
"content":"READY"
},
...
}
There is no reasoning field.
Measured time:
real 0m0.381s
This is a very large difference compared with reasoning enabled.
5. Same trivial request through OpenCode
Using GLM 4.7 Flash in OpenCode Build mode:
Reply with exactly: READY
OpenCode reported:
Thought: 1h 5m
Build · GLM 4.7 Flash · 1h 6m
This is despite the same Ollama model responding directly in seconds.
On another simple request with Qwen3.8 27B, OpenCode reported:
Thought: 50.2s
Plan · Qwen3.8 27B · 3m 13s
Another earlier simple OpenCode request with Qwen3.8 27B took:
Build · Qwen3.8 27B · 3m 37s
while direct Ollama requests were much faster.
6. Degenerate generation loop
During another OpenCode test with GLM 4.7 Flash, generation entered a loop
producing text similar to:
However, However, Other
...
Finally,
However,
Therefore,
Thus,
...
Therefore, However, However, Therefore...
...
The generation did not converge to a useful answer and had to be stopped.
7. OpenCode --variant none test
OpenCode 1.18.18 exposes:
--variant model variant (provider-specific reasoning effort,
e.g., high, max, minimal)
I tested:
time timeout 30s opencode run \
-m ollama/glm-4.7-flash:latest \
--variant none \
"Reply with exactly: READY"
Output:
> build · glm-4.7-flash:latest
Then it timed out:
real 0m30.051s
No READY response was produced.
Expected behavior
OpenCode should either:
- correctly handle the
reasoningfield returned by Ollama's
OpenAI-compatible endpoint without hanging or entering a generation loop,
or
-
provide a reliable way to pass:
"reasoning_effort": "none"to Ollama for models where reasoning should be disabled.
Ideally both should work.
Important observation
The performance difference is reproducible at the API level:
Ollama /v1 with reasoning:
~4-12 seconds depending on test
Ollama /v1 with reasoning_effort:none:
0.381 seconds
OpenCode:
30+ second timeout
several minutes
up to 1h06
or degenerate generation loop
The Ollama model is running 100% on GPU, so this does not appear to be caused
by CPU offloading.
The direct /v1/chat/completions tests also suggest that the Ollama server and
OpenAI-compatible endpoint themselves are responsive.
Question
Is OpenCode correctly handling Ollama's reasoning response field when using
@ai-sdk/openai-compatible?
Also, what is the supported way in OpenCode 1.18.18 to send the exact
OpenAI-compatible request parameter:
"reasoning_effort": "none"
to Ollama?
I found previous reports concerning OpenAI-compatible reasoning handling, but
the behavior described above is still reproducible with OpenCode 1.18.18 and
Ollama 0.32.13.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.