Fix JSONDecodeError in qwen3_coder tool parser#913
Open
BrunoCerberus wants to merge 1 commit intoml-explore:mainfrom
Open
Fix JSONDecodeError in qwen3_coder tool parser#913BrunoCerberus wants to merge 1 commit intoml-explore:mainfrom
BrunoCerberus wants to merge 1 commit intoml-explore:mainfrom
Conversation
The model sometimes outputs tool call parameters with single quotes or other Python-style literals instead of valid JSON for object/array types. The bare json.loads() call crashes the server with a JSONDecodeError. Fall back to ast.literal_eval() (already used for other types) when json.loads() fails, matching the existing error handling pattern in the parser.
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.
Summary
Fixes #912
_convert_param_value()crashes withJSONDecodeErrorwhen the model outputs object/array parameters with single quotes instead of valid JSONjson.loads()+ separateast.literal_eval()paths with a single try/except that falls back gracefullyChange
Test
Reproduced by running
Qwen3-Coder-30B-A3B-Instructviamlx_lm.serverwith tool-calling requests. The model intermittently outputs{'key': 'value'}instead of{"key": "value"}for object parameters, crashing the server. After this fix the server handles both formats.