Skip to content

Opencode + Qwen gives JSON output instead of writing to disk #29757

Closed as not planned

Description

@dvictori

Description

I'm using OpenCode 1.15.11 with Qwen2.5-code:7b running with ollama on my desktop.

I asked for a simple python script, saved into a file. Instead of creating the file on disk, OpenCode returned the JSON for the write command.

Image

I'm using the build agent and here is my ./.config/opencode/opencode.jsonc. I understand that I have given all the necessary permissions to the model

{
    "$schema": "https://opencode.ai/config.json",
    "permission": {
	"edit": "ask",
	"bash": "ask",
	"webfetch": "allow",
	"read": "ask",
	"write": "ask"
    },
   "provider": {
       "ollama": {
	   "name": "ollama",
	   "npm": "@ai-sdk/openai-compatible",
           "options": {
               "baseURL": "http://localhost:11434/v1"
           },
           "models": {
      	       "qwen2.5:7b": { "name": "Qwen2.5 7b" },
      	       "qwen2.5-coder:7b": { "name": "Qwen2.5 Code 7b" },
	       "qwen3.5:9b": { "name": "Qwen3.5 9b" }
           }
       }
   }
}

Plugins

No response

OpenCode version

1.15.11

Steps to reproduce

  1. Install ollama and Qwen2.5-code:7b (using 16k context size)
  2. Instruct opencode/Qwen2.5 to create the file

Screenshot and/or share link

No response

Operating System

Ubuntu

Terminal

No response

Activity

  1. github-actions commented on May 28, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. QQi44 commented on May 30, 2026

    @QQi44

    I have this issue too. It happens with windows

  3. QQi44 commented on May 30, 2026

    @QQi44
    Image

    u can sove this issue by Increase context length

  4. Virgula0 commented on May 31, 2026

    @Virgula0

    I'm using a bigger context length and it doesn't work on each of the following models, context size: 32k. Same problem of the OP. Version 1.15.10

    {
      "$schema": "https://opencode.ai/config.json",
      "model": "ollama/qwen2.5-coder:7b-32k",
      "provider": {
        "ollama": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "Ollama (Local Tool-Capable)",
          "options": {
            "baseURL": "http://127.0.0.1:11434/v1"
          },
          "models": {
            "qwen2.5-coder:7b-32k": {
              "name": "Qwen 2.5 Coder 7B (32k Context)"
            },
            "qwen2.5-coder:7b": {
              "name": "Qwen 2.5 Coder 7B (Default Context)"
            },
            "llama3.1:8b-32k": {
              "name": "Llama 3.1 8B (32k Context)"
            },
            "llama3.1:8b": {
              "name": "Llama 3.1 8B (Default Context)"
            }
          }
        }
      }
    }
    

    Update:

    adding

    "permission": {
    	"edit": "ask",
    	"bash": "ask",
    	"webfetch": "allow",
    	"read": "ask",
    	"write": "ask"
        },
    

    that was missing, llama3.1:8b-32k and lama3.1:8b seem to work. You need to specify the full path location where to write files but at least seems to produce something. Qwen still completely broken

    With working llama 3.1 what i'm noticing is that it is not able to write in correct locations:

    Image
    sh-5.3$ pwd
    /tmp/we
    sh-5.3$ cat ../test.txt 
    test
    
  5. dvictori commented on Jun 1, 2026

    @dvictori
    Author

    I tested with both default and 16k context length and none worked

  6. Virgula0 commented on Jun 1, 2026

    @Virgula0

    I tested with both default and 16k context length and none worked

    I found something working:

    google/gemma-4-E4B

    But with continue.dev visual studio code extension, not using opencode. Seems to have a lot of problems with small models

  7. dvictori commented on Jun 3, 2026

    @dvictori
    Author

    Upgraded to opencode v1.15.13

    Still, local Qwen model will not write to disk.
    Image

    Changing model to DeepSeek V4 Flash Free (from OpenCode Zen), it works as expected and the file is writen.
    Image

    Looks like it's a specific problem from Qwen?

  8. brtmax commented on Jun 16, 2026

    @brtmax

    Using @Virgula0 suggestion (Gemma 4 E4B) it works for me as well, but I could not get it to work with Qwen 2.5B Instruct.

    Maybe a heads-up for someone else: I had to create a new session in OpenCode for it to work

  9. DaGeRe commented on Jul 23, 2026

    @DaGeRe

    I also have the same issue and couldn't find any solution.

    When using qwen2.5-coder:32b, the output is:

    opencode run "/no_think generate a todo.md file with the contents 'hello world, from qwen3' in it"

    build · qwen2.5-coder:32b

    write: {"content": "hello world, from qwen3", "filePath": "/tmp/test/todo.md"}

    And no file is written.

    With Gemma4, the same works nicely:

    opencode run "/no_think generate a todo.md file with the contents 'hello world, from gemma' in it"

    build · gemma4:31b

    ✱ Glob "todo.md" 0 matches

    ← Write todo.md
    Wrote file successfully.

    Done.

    My opencode.json looks like this (with the line "model": "ollama/qwen2.5-coder:32b", being changed when gemma4 is used):

    {
      "$schema": "https://opencode.ai/config.json",
      "model": "ollama/qwen2.5-coder:32b",
      "provider": {
        "ollama": {
          "models": {
            "qwen2.5-coder:32b": {
              "name": "qwen2.5-coder"
            },
            "gemma4:31b": {
              "_launch": true,
              "name": "gemma4"
            }
          },
          "name": "ollama",
          "npm": "@ai-sdk/openai",
          "options": {
            "baseURL": "http://172.17.0.1:11434/v1",
            "apiKey": "anything"
          }
        }
      }
    }
    

    I used 1.18.4 and ollama 0.32.1, so everything should be up to date. If there is any workaround, I'd be happy to know about this.

    EDIT qwen3.6:27b works, since this is much newer and has comparable size, it probably makes sense to just switch to this model.

  10. github-actions commented on Sep 23, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  11. rogerclarkmelbourne commented on Oct 31, 2026

    @rogerclarkmelbourne

    I'm also having the same problem with any of the qwen models I've tried.

    Basically none of the invocation commands from qwen work in OpenCode.

    qwen2.5-coder:7b responses are different from qwen3.5:9b responses, but neither work.

    This problem is also not isolated to OpenCode. I tried running Claude-Code locally and connecting it to Ollama -> qwen2.5-coder:7b and basically it has the same problem as OpenCode.

    As qwen2.5 and qwen3.5 responses seem to be different, the only way this could be resolved would be for opencode to be able to be configured to handle the difference response formats for these 2 LLMs, and as they are not the latest version of qwen, I doubt they would want to devote effort to support them :-(

    As Gemma4 seems to have worked for some people, I'll give that a go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions