Description
When using OpenCode with Ollama or other local OpenAI-compatible endpoints, if the model response includes a field reasoning (as produced by Ollama), the result is an infinite spin on 'Build - ' and high CPU, with no output. OpenCode expects Copilot/OpenAI-specific fields: reasoning_text or reasoning_opaque only, and does not accept the generic reasoning field. As a result, UI never recovers. This is confirmed for Ollama 0.20.4 (gemma4, qwen3.5) on Arch Linux. See reproduction step 5 for actual Ollama response proof.
I've tested with a patched version of OpenCode and it works.
modified packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-chat-language-model.ts
@@ -757,6 +757,7 @@ const OpenAICompatibleChatResponseSchema = z.object({
// Copilot-specific reasoning fields
reasoning_text: z.string().nullish(),
reasoning_opaque: z.string().nullish(),
+ reasoning: z.string().nullish(), // Ollama-compatibility
tool_calls: z
.array(
z.object({
@@ -792,6 +793,7 @@ const createOpenAICompatibleChatChunkSchema = <ERROR_SCHEMA extends z.core.$ZodT
// Copilot-specific reasoning fields
reasoning_text: z.string().nullish(),
reasoning_opaque: z.string().nullish(),
+ reasoning: z.string().nullish(), // Ollama-compatibility
tool_calls: z
.array(
z.object({
Plugins
No response
OpenCode version
1.4.3
Steps to reproduce
- Launch Ollama (0.20.4 or later) with a compatible chat model (e.g., gemma4, qwen3.5)
- Configure OpenCode to use your local OpenAI-compatible backend:
ollama launch opencode
- Prompt the model (any message)
- Observe: UI spins/hangs with high CPU, never returns output
- Inspect Ollama's response JSON, which looks like:
{
"id": "chatcmpl-123",
"object": "chat.completion",
"choices": [{
"message": {
"role": "assistant",
"content": "...",
"reasoning": "Some chain-of-thought reasoning steps"
}
}]
}
- Confirm OpenCode only parses
reasoning_text/reasoning_opaque (see openai-compatible-chat-language-model.ts), not reasoning.
- Workaround: Patch the Zod schema in OpenCode to accept
reasoning: z.string().nullish().
Screenshot and/or share link
No response
Operating System
Linux (Arch)
Terminal
Kitty
Description
When using OpenCode with Ollama or other local OpenAI-compatible endpoints, if the model response includes a field
reasoning(as produced by Ollama), the result is an infinite spin on 'Build - ' and high CPU, with no output. OpenCode expects Copilot/OpenAI-specific fields:reasoning_textorreasoning_opaqueonly, and does not accept the genericreasoningfield. As a result, UI never recovers. This is confirmed for Ollama 0.20.4 (gemma4,qwen3.5) on Arch Linux. See reproduction step 5 for actual Ollama response proof.I've tested with a patched version of OpenCode and it works.
Plugins
No response
OpenCode version
1.4.3
Steps to reproduce
ollama launch opencodereasoning_text/reasoning_opaque(seeopenai-compatible-chat-language-model.ts), notreasoning.reasoning: z.string().nullish().Screenshot and/or share link
No response
Operating System
Linux (Arch)
Terminal
Kitty