fix(write): handle array content from GLM and Qwen models
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
UnmarshalJSONmethod forWriteParams - Handles both string and array formats
- Zero breaking changes
Related
- User report: Community feedback on GLM/Qwen compatibility
- VeniceCode: https://github.com/georgeglarson/venicecode
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.
I have read the Contributor License Agreement (CLA) and hereby sign the CLA.
I have read the Contributor License Agreement (CLA) and hereby sign the CLA.
recheck