crush icon indicating copy to clipboard operation
crush copied to clipboard

fix(write): handle array content from GLM and Qwen models

Open georgeglarson opened this issue 1 month ago • 3 comments

Problem

Some models (GLM 4.6, Qwen 3 Coder 480B) send the write tool's content parameter as an array of strings instead of a single string, causing validation errors:

The write tool was called with invalid arguments:
"Invalid input: expected string, received array"

Solution

This PR adds a custom UnmarshalJSON method to WriteParams that:

  • ✅ Accepts string content (existing behavior, fully backward compatible)
  • ✅ Accepts array of strings (joins with newlines)
  • ✅ Provides clear error messages for invalid types

The fix is transparent to models that send strings and enables compatibility with models that send arrays.

Affected Models

  • GLM 4.6
  • Qwen 3 Coder 480B
  • Any other models that send array content

Testing

Tested with Venice.ai models via VeniceCode (Venice.ai-optimized fork of Crush).

Code Changes

Adds 35 lines to internal/agent/tools/write.go:

  • Custom UnmarshalJSON method for WriteParams
  • Handles both string and array formats
  • Zero breaking changes

Related

  • User report: Community feedback on GLM/Qwen compatibility
  • VeniceCode: https://github.com/georgeglarson/venicecode

georgeglarson avatar Nov 24 '25 20:11 georgeglarson

Thank you for your submission. We really appreciate it! Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request comment same as the below format.


I have read the Contributor License Agreement (CLA) and hereby sign the CLA.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

charmcli avatar Nov 24 '25 20:11 charmcli

I have read the Contributor License Agreement (CLA) and hereby sign the CLA.

georgeglarson avatar Nov 24 '25 20:11 georgeglarson

I have read the Contributor License Agreement (CLA) and hereby sign the CLA.

recheck

georgeglarson avatar Nov 25 '25 18:11 georgeglarson