Uh oh!
There was an error while loading. Please reload this page.
fix(write): support array content from Venice.ai models - #4715
fix(write): support array content from Venice.ai models#4715georgeglarson wants to merge 4 commits into
Conversation
Some AI models (e.g., GLM 4.6, Qwen 3 Coder 480B) send tool call content as arrays instead of strings. This causes the write tool to fail with: 'Invalid input: expected string, received array' This fix uses Zod's preprocess function to handle both formats: - String content: passed through unchanged - Array content: joined with newlines - Other types: converted to string This maintains backward compatibility while enabling support for Venice.ai and similar models that use array-based content formatting. Related: charmbracelet/crush#1508
There was a problem hiding this comment.
Pull request overview
This pull request adds support for AI models (e.g., GLM 4.6, Qwen 3 Coder 480B from Venice.ai) that send tool call content as arrays instead of strings. The fix uses Zod's preprocess function to normalize array-based content by joining elements with newlines, while maintaining backward compatibility with string-based content.
Key changes:
- Added preprocessing logic to handle both string and array content formats
- Used
z.preprocess()to transform array inputs into newline-separated strings before validation - Maintained backward compatibility with existing string-based content
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
spoons-and-mirrors
commented
Nov 25, 2025
hey @georgeglarson, are you sure the models aren't calling the tool improperly ? does this only happen with the write tool or also other tools? in the mean time, you can expose the experimental batch tool: hope this helps |
Hey @spoons-and-mirrors! Great question. TL;DR: The models are following the OpenAI spec correctly - they're allowed to send arrays. This happens specifically with the Why arrays? Does it affect other tools?
The fix |
spoons-and-mirrors
commented
Nov 25, 2025
ProlowN
commented
Nov 26, 2025
This setting does not make the error go away
Z AI and others do work, its not a model issue per say, its the way the write/ediit tool is being used i believe |
spoons-and-mirrors
commented
Nov 26, 2025
Not sure I understand what you mean, but as I showed in my screenshot, I can have glm do what this PR is supposedly trying to fix. |
ProlowN
commented
Nov 26, 2025
So, the issue isnt the model itself its how the inference provider has it setup. |
ProlowN
commented
Nov 26, 2025
Let me rephrase that, the issue isnt how the provider has it setup, as its per OpenAI spec. |
znake
commented
Nov 29, 2025
@spoons-and-mirrors any chance this will get merged. Lots of venice.ai user are waiting for this fix 🙏🙏🙏 |
@znake I've pinged the team, not much more i can do. Are you sure this solves venice.ai user issues tho? how about other tools? did you try the batch tool ? which could help maybe? |
ProlowN
commented
Dec 1, 2025
@spoons-and-mirrors Ive tried enabling the experimental batching tool feature and it did not have any effect. |
KevinPoorDeveloper
commented
Dec 5, 2025
Can't wait for this PR to get merged! |
KevinPoorDeveloper
commented
Dec 16, 2025
@rekram1-node Can this go live? |
f1ae801 to
08fa7f7CompareClosing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR. |


Some AI models (e.g., GLM 4.6, Qwen 3 Coder 480B) send tool call content as arrays instead of strings. This causes the write tool to fail with: 'Invalid input: expected string, received array'
This fix uses Zod's preprocess function to handle both formats:
This maintains backward compatibility while enabling support for Venice.ai and similar models that use array-based content formatting.
Related: charmbracelet/crush#1508