qwen3_coder tool parser returns raw string for parameters whose schema has no top-level "type" (oneOf/anyOf)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start in mlx_lm/tool_parsers/qwen3_coder.py at _convert_param_value() and reproduce the behavior with the oneOf schema and model output given in the issue. Confirm that parameters without a top-level type are parsed as JSON objects when valid, while invalid JSON still remains a raw string; done means arguments.plugin is a dict for the supplied reproduction.
Written by the indexing model from the issue text.
Description
mlx-lm 0.31.3, mlx_lm/tool_parsers/qwen3_coder.py, _convert_param_value()
If a tool parameter's JSON schema has no top-level "type" key (e.g. a oneOf of object
branches, which is valid JSON Schema and what OpenAI-style tool definitions allow),
the parser falls into:
else:
param_type = "string"
and returns the model's XML parameter body verbatim. The model emitted a JSON object,
so the client receives "plugin": "{\"kind\": \"new\", ...}" (a string) instead of an
object, and schema validation on the client fails.
Repro schema:
{"plugin": {"oneOf": [
{"type":"object","properties":{"kind":{"const":"new"},"idPrefix":{"type":"string"}},"required":["kind","idPrefix"]},
{"type":"object","properties":{"kind":{"const":"existing"},"pluginId":{"type":"string"}},"required":["kind","pluginId"]}]}}
Model output:
<function=f><parameter=plugin>{"kind": "new", "idPrefix": "abc"}
Actual: arguments.plugin == '{"kind": "new", "idPrefix": "abc"}' (str)
Expected: arguments.plugin == {"kind": "new", "idPrefix": "abc"} (dict)
Suggested fix: when "type" is absent, attempt json.loads(param_value) and fall back
to the raw string on failure. Patch:
else:
try:
return json.loads(param_value)
except (json.JSONDecodeError, ValueError):
return param_value
Seen via oMLX 0.7.0.dev3 serving Qwen3.6-35B-A3B; the client was DeepSeek Harness
(dsh), whose cordis_define tool uses a oneOf parameter.
- Dominant language
- Python
- Stars
- 7.1k
- Forks
- 1.1k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 54
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ml-explore/mlx-lm
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
ml-explore/mlx-lm#1908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ml-explore/mlx-lm#1906 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ml-explore/mlx-lm#1884 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ml-explore/mlx-lm#1792 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ml-explore/mlx-lm#1732 ·
All issues in ml-explore/mlx-lm
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100