qwen3-coder fails to call edit tool #4217

Open
opened 2026-02-16 17:43:03 -05:00 by yindo · 12 comments
Owner

Originally created by @mausch on GitHub (Jan 5, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

When using https://openrouter.ai/qwen/qwen3-coder:free it fails to call the edit tool.

It fails over and over again with:

Error: The edit tool was called with invalid arguments: [
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "oldString"
    ],
    "message": "Invalid input: expected string, received object"
  },
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "newString"
    ],
    "message": "Invalid input: expected string, received object"
  }
].
Please rewrite the input so it satisfies the expected schema.

Plugins

none

OpenCode version

1.1.1

Steps to reproduce

  1. Set provider to Openrouter
  2. Set model to qwen/qwen3-coder:free
  3. Ask it to make any edits

Screenshot and/or share link

Image

Operating System

NixOS

Terminal

xterm

Originally created by @mausch on GitHub (Jan 5, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description When using https://openrouter.ai/qwen/qwen3-coder:free it fails to call the edit tool. It fails over and over again with: ``` Error: The edit tool was called with invalid arguments: [ { "expected": "string", "code": "invalid_type", "path": [ "oldString" ], "message": "Invalid input: expected string, received object" }, { "expected": "string", "code": "invalid_type", "path": [ "newString" ], "message": "Invalid input: expected string, received object" } ]. Please rewrite the input so it satisfies the expected schema. ``` ### Plugins none ### OpenCode version 1.1.1 ### Steps to reproduce 1. Set provider to Openrouter 2. Set model to `qwen/qwen3-coder:free` 3. Ask it to make any edits ### Screenshot and/or share link <img width="1920" height="1037" alt="Image" src="https://github.com/user-attachments/assets/394149bc-b197-4156-b5d4-e2c44e1a577a" /> ### Operating System NixOS ### Terminal xterm
yindo added the bugnix labels 2026-02-16 17:43:03 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 5, 2026):

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

  • #6838: Tool.edit should receive json object - Similar issue where LLM passes JSON objects instead of strings to edit tool parameters

The root cause appears to be that some LLM models (like Qwen3-coder) pass JSON objects for oldString and newString when they should pass strings. This is similar to the broader issue documented in #6838 where models struggle with properly stringifying JSON content for the edit tool.

Feel free to ignore if your specific case differs from these existing issues.

@github-actions[bot] commented on GitHub (Jan 5, 2026): This issue might be a duplicate of existing issues. Please check: - #6838: Tool.edit should receive json object - Similar issue where LLM passes JSON objects instead of strings to edit tool parameters The root cause appears to be that some LLM models (like Qwen3-coder) pass JSON objects for `oldString` and `newString` when they should pass strings. This is similar to the broader issue documented in #6838 where models struggle with properly stringifying JSON content for the edit tool. Feel free to ignore if your specific case differs from these existing issues.
Author
Owner

@PhantomKnight287 commented on GitHub (Jan 6, 2026):

Facing same on Macos 15.6.1 and Ghostty

@PhantomKnight287 commented on GitHub (Jan 6, 2026): Facing same on Macos 15.6.1 and Ghostty
Author
Owner

@arne-fuchs commented on GitHub (Jan 20, 2026):

Same here. Qwen is hard to use with opencode and always made problems. AFAIK: the problem is not opencode in particular but also qwen3 misunderstanding the tools/capabilities provided by opencode. I heard of proxies acting as "man in the middle" fixing tool calling for qwen3.
Edit: Please notice that those proxies only have been tested with Qwen3-Coder-30B-A3B-Instruct. Other Qwen3 variations may have different problems. I had no luck the versions provided by ollama

@arne-fuchs commented on GitHub (Jan 20, 2026): Same here. Qwen is hard to use with opencode and always made problems. AFAIK: the problem is not opencode in particular but also qwen3 misunderstanding the tools/capabilities provided by opencode. I heard of [proxies acting as "man in the middle" fixing tool calling](https://github.com/florath/qwen3-call-patch-proxy) for qwen3. Edit: Please notice that those proxies only have been tested with Qwen3-Coder-30B-A3B-Instruct. Other Qwen3 variations may have different problems. I had no luck the versions provided by ollama
Author
Owner

@GiveMe-A-Name commented on GitHub (Jan 28, 2026):

Same problems with GLM4.7

@GiveMe-A-Name commented on GitHub (Jan 28, 2026): Same problems with GLM4.7
Author
Owner

@nabil86 commented on GitHub (Feb 4, 2026):

I have same issue with GLM 4.7-flash & qwen3-coder .
i'm using ollama (localy)

@nabil86 commented on GitHub (Feb 4, 2026): I have same issue with GLM 4.7-flash & qwen3-coder . i'm using ollama (localy)
Author
Owner

@GiveMe-A-Name commented on GitHub (Feb 4, 2026):

Every time I want read or write files using ai. I will occur error.
And this issues don't solved in opencode@1.1.15

It's so sad

Image
@GiveMe-A-Name commented on GitHub (Feb 4, 2026): Every time I want read or write files using ai. I will occur error. And this issues don't solved in opencode@1.1.15 It's so sad <img width="1080" height="802" alt="Image" src="https://github.com/user-attachments/assets/112608f1-573c-4be1-8b2d-922368c8770f" />
Author
Owner

@giraudremi92 commented on GitHub (Feb 5, 2026):

same on qwen 3 coder next 80b
sometimes its go on with cat

Image
@giraudremi92 commented on GitHub (Feb 5, 2026): same on qwen 3 coder next 80b sometimes its go on with cat <img width="1245" height="599" alt="Image" src="https://github.com/user-attachments/assets/44041399-b180-4b4c-974f-5be8dfdd1703" />
Author
Owner

@itsShnik commented on GitHub (Feb 10, 2026):

Same problem with gemini-3-pro-preview high (variant)

@itsShnik commented on GitHub (Feb 10, 2026): Same problem with gemini-3-pro-preview high (variant)
Author
Owner

@CVeRiTy commented on GitHub (Feb 13, 2026):

Very similar problem with Qwen3-Coder-Next. I receive this consistently when it tries to call the write tool:

The write tool was called with invalid arguments: [ { "expected": "string", "code": "invalid_type", "path": [ "filePath" ], "message": "Invalid input: expected string, received undefined" } ]. Please rewrite the input so it satisfies the expected schema.

I receive this error a fair bit. Eventually it figures out to use a different method, or I cancel and tell it to use a different method.

@CVeRiTy commented on GitHub (Feb 13, 2026): Very similar problem with Qwen3-Coder-Next. I receive this consistently when it tries to call the write tool: The write tool was called with invalid arguments: [ { "expected": "string", "code": "invalid_type", "path": [ "filePath" ], "message": "Invalid input: expected string, received undefined" } ]. Please rewrite the input so it satisfies the expected schema. I receive this error a fair bit. Eventually it figures out to use a different method, or I cancel and tell it to use a different method.
Author
Owner

@mihaj commented on GitHub (Feb 13, 2026):

I get this quite a but with Qwen3-Coder-Next. not sure if it has anything to do with this long token generation steps (more than 1500 fore example).

I am using LM Studio 0.4.2 (Build 2), OpenCode 1.1.62 and Llama 2.2.0 runtime in LM Studio. Model is from Qwen3-Coder-Next Unsloth MXFP4.

@mihaj commented on GitHub (Feb 13, 2026): I get this quite a but with Qwen3-Coder-Next. not sure if it has anything to do with this long token generation steps (more than 1500 fore example). I am using LM Studio 0.4.2 (Build 2), OpenCode 1.1.62 and Llama 2.2.0 runtime in LM Studio. Model is from Qwen3-Coder-Next Unsloth MXFP4.
Author
Owner

@gtrak commented on GitHub (Feb 13, 2026):

There's some upstream bugs:
https://github.com/ggml-org/llama.cpp/issues/19430 hard crash
https://github.com/ggml-org/llama.cpp/issues/19382 broken filePath json

Is there any known workaround?

@gtrak commented on GitHub (Feb 13, 2026): There's some upstream bugs: https://github.com/ggml-org/llama.cpp/issues/19430 hard crash https://github.com/ggml-org/llama.cpp/issues/19382 broken filePath json Is there any known workaround?
Author
Owner

@BVEsun commented on GitHub (Feb 16, 2026):

Any update for this bug?

Qwen3.5 will release soon, hope this bug won't happen on Qwen3.5

@BVEsun commented on GitHub (Feb 16, 2026): Any update for this bug? Qwen3.5 will release soon, hope this bug won't happen on Qwen3.5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4217