anomalyco / anomalyco/opencode
[Ollama] /thinking toggle and think parameter not passed to local Ollama provider API requests
@jlongster is already working on this.
Since Sep 4, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Problem
When using OpenCode with a local Ollama provider (not ollama-cloud), the /thinking toggle has no effect. The think parameter is never included in API requests sent to the Ollama Chat API (POST /api/chat).
This means there is no way to control reasoning behavior for thinking-capable models (Qwen3, QwQ, DeepSeek-R1, etc.) served via a local Ollama instance.
Additionally, OpenCode does not parse <think>...</think> tags from the model's response stream — reasoning content is dumped inline with the regular response text, making it unreadable.
Note: Issue #36638 describes a similar problem for ollama-cloud variants. This issue is specifically about the local Ollama provider (@ai-sdk/openai-compatible), which has the same underlying problem but through a different code path.
Steps to Reproduce
- Configure a local Ollama provider in
~/.config/opencode/config.json:
{
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama",
"options": {
"baseURL": "http://192.168.1.90:11434/v1"
},
"models": {
"qwen3.8:27b": {
"name": "qwen3.8:27b"
}
}
}
}
}
- Launch
opencodeand select the model - Toggle
/thinkingon - Send any prompt (e.g., "Solve 2+2 step by step")
- Observe the response
Expected Behavior
- The
/thinkingtoggle sends"think": true(or"think": falsewhen off) as a top-level field in the Ollama Chat API request body - When
thinkis enabled,<think>...</think>blocks in the model output are parsed and rendered separately (dimmed text, collapsible section, etc.) - The
/thinkingtoggle provides the same level of control as the Ollama CLI (ollama run --think=true) or the raw API ("think": truein JSON)
Actual Behavior
- The
thinkparameter is absent from the API request — confirmed by inspecting Ollama server logs - The
/thinkingtoggle has zero effect on model behavior - When the model produces
<think>...</think>blocks (thinking-enabled models), the reasoning content appears inline as raw text mixed with the actual response - The only workaround is embedding
/no_thinkin the model's system prompt via Ollama Modelfile, which is unreliable (soft instruction, not enforced)
Workaround
Currently, the only way to suppress reasoning output is to bake a system prompt into the model via Ollama Modelfile:
FROM qwen3.8:27b
SYSTEM You are a helpful coding assistant. Provide direct answers without any internal reasoning, thoughts, or <think> tags.
This is a soft instruction that the model may ignore. There is no reliable workaround for enabling/disabling thinking on demand.
Environment
| Component | Version |
|---|---|
| OpenCode | latest |
| Ollama | 0.32.13 |
| Model | qwen3.8:27b (supports think parameter) |
| OS | Debian Linux |
| Provider | local Ollama (@ai-sdk/openai-compatible) |
Proposed Fix
-
Pass
thinkparameter: When the active provider targets an Ollama instance, translate the/thinkingtoggle into"think": true/falsein the API request body. This aligns with the Ollama Chat API spec wherethinkis a top-level parameter. -
Parse
<think>tags: Implement stream parsing for<think>...</think>markers in the response. Display reasoning content in a visually distinct block (dimmed, collapsible, or prefixed). This would match the behavior of other terminal coding agents (e.g., Pi Coding Agent) that already handle this correctly. -
Add
thinkto provider config: Allow explicit configuration inopencode.json:
{
"provider": {
"ollama": {
"models": {
"qwen3.8:27b": {
"name": "qwen3.8:27b",
"reasoning": true,
"variants": {
"high": { "think": true },
"off": { "think": false }
}
}
}
}
}
}
References
- Ollama Chat API — think parameter
- Issue #36638 — same problem for ollama-cloud provider
- Ollama CLI equivalent:
ollama run qwen3.8:27b --think=true
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.