#1907·mlx-lm

qwen3_coder tool parser returns raw string for parameters whose schema has no top-level "type" (oneOf/anyOf)

Author: petriemattCreated Sep 21, 2026Updated Sep 21, 2026

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.