Fix: Convert ContentPart list content to string in message extraction, fixes 500 Error with Qwen Code CLI#433
Merged
jundot merged 1 commit intojundot:mainfrom Mar 29, 2026
Conversation
- _extract_text_from_content_list(): Enhanced to handle edge cases - extract_text_content(): Add ContentPart list handling for tool messages and final safety check to ensure all content is string type - extract_multimodal_content(): Add ContentPart list handling for tool messages - extract_harmony_messages(): Add ContentPart list handling for tool and assistant messages Fixes ValueError when messages with content arrays are sent to MLX models. Co-authored-by: Qwen-Coder <[email protected]>
jundot
reviewed
Mar 29, 2026
Owner
jundot
left a comment
There was a problem hiding this comment.
Thanks for the fix! Tool messages with list content was a real gap.
I'll clean up a couple of things in a follow-up commit (remove the safety check catch-all, refactor some inline duplication, add a few more tests).
Owner
|
@mbauer v0.3.0rc1 is out with your ContentPart fix included. https://github.com/jundot/omlx/releases/tag/v0.3.0rc1 — if you get a chance, please give it a test and let me know if anything looks off. thanks! |
AlexTzk
pushed a commit
to AlexTzk/omlx
that referenced
this pull request
Mar 29, 2026
…duplication, add tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A note ahead: this is AI coded with minor guidance from me. The patch is small (31 lines added) and it fixes a 500 error.
Summary
When using Qwen Code CLI, I got 500 Errors with oMLX but not with plain mlx-server.
The error ValueError: text input must be of type 'str'... was caused by messages with content as a list of ContentPart objects being passed to the MLX tokenizer's apply_chat_template method instead of being converted to strings first.
Root Cause
Fix Applied
Tests Added
All existing tests continue to pass.
Fixes ValueError when messages with content arrays are sent to MLX models.