vllm - 💡(How to fix) Fix [Bug]: qwen3xml_tool_parser: ast.literal_eval fails on JSON booleans/null, causing complex array arguments to be string-encoded instead of native arrays

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

When a tool schema includes an array of objects as a parameter (e.g. questions: array<object>), the qwen3xml_tool_parser delivers the argument to clients as a JSON-encoded string instead of a native JSON array. Any client that schema-validates tool call arguments receives a type error. except Exception:

Root Cause

Root Cause In qwen3xml_tool_parser.py, the StreamingXMLToolCallParser._end_element method handles "deferred" parameters (array and object types) by accumulating the raw parameter text and then parsing it at </parameter> time.

Fix Action

Fix / Workaround

============================== CPU Info

Architecture: aarch64 CPU op-mode(s): 64-bit Byte Order: Little Endian CPU(s): 20 On-line CPU(s) list: 0-19 Vendor ID: ARM Model name: Cortex-X925 Model: 1 Thread(s) per core: 1 Core(s) per socket: 10 Socket(s): 1 Stepping: r0p1 Frequency boost: disabled CPU(s) scaling MHz: 100% CPU max MHz: 3900.0000 CPU min MHz: 1378.0000 BogoMIPS: 2000.00 Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti ecv afp wfxt Model name: Cortex-A725 Model: 1 Thread(s) per core: 1 Core(s) per socket: 10 Socket(s): 1 Stepping: r0p1 CPU(s) scaling MHz: 100% CPU max MHz: 2808.0000 CPU min MHz: 338.0000 BogoMIPS: 2000.00 Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti ecv afp wfxt L1d cache: 1.3 MiB (20 instances) L1i cache: 1.3 MiB (20 instances) L2 cache: 25 MiB (20 instances) L3 cache: 24 MiB (2 instances) NUMA node(s): 1 NUMA node0 CPU(s): 0-19 Vulnerability Gather data sampling: Not affected Vulnerability Ghostwrite: Not affected Vulnerability Indirect target selection: Not affected Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Old microcode: Not affected Vulnerability Reg file data sampling: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; __user pointer sanitization Vulnerability Spectre v2: Mitigation; CSV2, BHB Vulnerability Srbds: Not affected Vulnerability Tsa: Not affected Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Not affected

Code Example

Successfully copied 36.9kB to vllm-server:/tmp/collect_env.py
Collecting environment information...
==============================
        System Info
==============================
OS                           : Ubuntu 24.04.4 LTS (aarch64)
GCC version                  : (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Clang version                : Could not collect
CMake version                : version 3.31.6
Libc version                 : glibc-2.39

==============================
       PyTorch Info
==============================
PyTorch version              : 2.12.0a0+0291f960b6.nv26.04.48445190
Is debug build               : False
CUDA used to build PyTorch   : 13.2
ROCM used to build PyTorch   : N/A
XPU used to build PyTorch    : N/A

==============================
      Python Environment
==============================
Python version               : 3.12.3 (main, Mar  3 2026, 12:15:18) [GCC 13.3.0] (64-bit runtime)
Python platform              : Linux-6.17.0-1018-nvidia-aarch64-with-glibc2.39

==============================
       CUDA / GPU Info
==============================
Is CUDA available            : True
CUDA runtime version         : 13.2.78
CUDA_MODULE_LOADING set to   :
GPU models and configuration : GPU 0: NVIDIA GB10
Nvidia driver version        : 580.142
cuDNN version                : Probably one of the following:
/usr/lib/aarch64-linux-gnu/libcudnn.so.9.21.0
/usr/lib/aarch64-linux-gnu/libcudnn_adv.so.9.21.0
/usr/lib/aarch64-linux-gnu/libcudnn_cnn.so.9.21.0
/usr/lib/aarch64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.21.0
/usr/lib/aarch64-linux-gnu/libcudnn_engines_tensor_ir.so.9.21.0
/usr/lib/aarch64-linux-gnu/libcudnn_graph.so.9.21.0
/usr/lib/aarch64-linux-gnu/libcudnn_heuristic.so.9.21.0
/usr/lib/aarch64-linux-gnu/libcudnn_ops.so.9.21.0
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  20
On-line CPU(s) list:                     0-19
Vendor ID:                               ARM
Model name:                              Cortex-X925
Model:                                   1
Thread(s) per core:                      1
Core(s) per socket:                      10
Socket(s):                               1
Stepping:                                r0p1
Frequency boost:                         disabled
CPU(s) scaling MHz:                      100%
CPU max MHz:                             3900.0000
CPU min MHz:                             1378.0000
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti ecv afp wfxt
Model name:                              Cortex-A725
Model:                                   1
Thread(s) per core:                      1
Core(s) per socket:                      10
Socket(s):                               1
Stepping:                                r0p1
CPU(s) scaling MHz:                      100%
CPU max MHz:                             2808.0000
CPU min MHz:                             338.0000
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti ecv afp wfxt
L1d cache:                               1.3 MiB (20 instances)
L1i cache:                               1.3 MiB (20 instances)
L2 cache:                                25 MiB (20 instances)
L3 cache:                                24 MiB (2 instances)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-19
Vulnerability Gather data sampling:      Not affected
Vulnerability Ghostwrite:                Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Old microcode:             Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

==============================
Versions of relevant libraries
==============================
[pip3] flashinfer-python==0.6.7.post3+0a7dba17.nv26.4.cu132.48455225
[pip3] numpy==2.1.0
[pip3] nvidia-cudnn-frontend==1.18.0
[pip3] nvidia-cutlass-dsl==4.5.0.dev0
[pip3] nvidia-cutlass-dsl-libs-base==4.5.0.dev0
[pip3] nvidia-ml-py==13.595.45
[pip3] pyzmq==27.1.0
[pip3] torch==2.12.0a0+0291f960b6.nv26.4.48445190
[pip3] torch_c_dlpack_ext==0.1.5
[pip3] torchaudio==2.11.0
[pip3] torchvision==0.26.0a0+48956e05.nv26.4.48445190
[pip3] transformers==4.57.6
[pip3] triton==3.6.0+git5d72932fc5.nv26.3
[conda] Could not collect

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.19.0+6bc3197f.nv26.04.48680843
vLLM Build Flags:
  CUDA Archs: 8.0 8.6 9.0 10.0 11.0 12.0+PTX; ROCm: Disabled; XPU: Disabled
GPU Topology:
        GPU0    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      0-19    0               N/A

Legend:

  X    = Self
  SYS  = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
  NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
  PHB  = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
  PXB  = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
  PIX  = Connection traversing at most a single PCIe bridge
  NV#  = Connection traversing a bonded set of # NVLinks

==============================
     Environment Variables
==============================
CUDA_VERSION=13.2.1.009
CUDA_DRIVER_VERSION=595.58.03
NVIDIA_REQUIRE_CUDA=cuda>=9.0
NCCL_VERSION=2.29.7
CUBLAS_VERSION=13.4.0.1
CUBLASMP_VERSION=0.8.1.2360
CUDNN_VERSION=9.21.0.82
CUDNN_FRONTEND_VERSION=1.22.1
CUDA_ARCH_LIST=8.0 8.6 9.0 10.0 11.0 12.0
LD_LIBRARY_PATH=/usr/local/lib/python3.12/dist-packages/torch/lib:/usr/local/lib/python3.12/dist-packages/torch_tensorrt/lib:/usr/local/nixlbench/lib:/usr/local/lib:/opt/amazon/efa/lib:/usr/lib:/usr/local/cuda/compat/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/nixl/lib/x86_64-linux-gnu:/usr/local/nixl/lib/aarch64-linux-gnu
NVIDIA_VISIBLE_DEVICES=all
NVIDIA_DRIVER_CAPABILITIES=compute,utility,video
NVIDIA_PRODUCT_NAME=vLLM
CUDA_COMPONENT_LIST=cccl crt nvrtc driver-dev culibos-dev cudart cudart-dev nvcc tileiras
CUDA_HOME=/usr/local/cuda
CUDA_HOME=/usr/local/cuda
TORCH_CUDA_ARCH_LIST=8.0 8.6 9.0 10.0 11.0 12.0+PTX
MAX_JOBS=12
PYTORCH_TRITON_VERSION=3.6.0+git5d72932fc5.nv26.3
NVIDIA_VLLM_VERSION=26.04
NVIDIA_BUILD_ID=299333414
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1
TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_root
RAW_BUFFERClick to expand / collapse

Your current environment

<details> vLLM version: 0.19.0+6bc (NGC container nvcr.io/nvidia/vllm:26.04-py3) Hardware: NVIDIA DGX Spark GB10 (Blackwell, sm_121) Model: Qwen/Qwen3.6-27B-FP8 Tool call parser flag: --tool-call-parser qwen3_xml Python: 3.12 Affected file: /usr/local/lib/python3.12/dist-packages/vllm/tool_parsers/qwen3xml_too_parser.py ```text Successfully copied 36.9kB to vllm-server:/tmp/collect_env.py Collecting environment information... ============================== System Info ============================== OS : Ubuntu 24.04.4 LTS (aarch64) GCC version : (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0 Clang version : Could not collect CMake version : version 3.31.6 Libc version : glibc-2.39

============================== PyTorch Info

PyTorch version : 2.12.0a0+0291f960b6.nv26.04.48445190 Is debug build : False CUDA used to build PyTorch : 13.2 ROCM used to build PyTorch : N/A XPU used to build PyTorch : N/A

============================== Python Environment

Python version : 3.12.3 (main, Mar 3 2026, 12:15:18) [GCC 13.3.0] (64-bit runtime) Python platform : Linux-6.17.0-1018-nvidia-aarch64-with-glibc2.39

============================== CUDA / GPU Info

Is CUDA available : True CUDA runtime version : 13.2.78 CUDA_MODULE_LOADING set to : GPU models and configuration : GPU 0: NVIDIA GB10 Nvidia driver version : 580.142 cuDNN version : Probably one of the following: /usr/lib/aarch64-linux-gnu/libcudnn.so.9.21.0 /usr/lib/aarch64-linux-gnu/libcudnn_adv.so.9.21.0 /usr/lib/aarch64-linux-gnu/libcudnn_cnn.so.9.21.0 /usr/lib/aarch64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.21.0 /usr/lib/aarch64-linux-gnu/libcudnn_engines_tensor_ir.so.9.21.0 /usr/lib/aarch64-linux-gnu/libcudnn_graph.so.9.21.0 /usr/lib/aarch64-linux-gnu/libcudnn_heuristic.so.9.21.0 /usr/lib/aarch64-linux-gnu/libcudnn_ops.so.9.21.0 HIP runtime version : N/A MIOpen runtime version : N/A Is XNNPACK available : True

============================== CPU Info

Architecture: aarch64 CPU op-mode(s): 64-bit Byte Order: Little Endian CPU(s): 20 On-line CPU(s) list: 0-19 Vendor ID: ARM Model name: Cortex-X925 Model: 1 Thread(s) per core: 1 Core(s) per socket: 10 Socket(s): 1 Stepping: r0p1 Frequency boost: disabled CPU(s) scaling MHz: 100% CPU max MHz: 3900.0000 CPU min MHz: 1378.0000 BogoMIPS: 2000.00 Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti ecv afp wfxt Model name: Cortex-A725 Model: 1 Thread(s) per core: 1 Core(s) per socket: 10 Socket(s): 1 Stepping: r0p1 CPU(s) scaling MHz: 100% CPU max MHz: 2808.0000 CPU min MHz: 338.0000 BogoMIPS: 2000.00 Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti ecv afp wfxt L1d cache: 1.3 MiB (20 instances) L1i cache: 1.3 MiB (20 instances) L2 cache: 25 MiB (20 instances) L3 cache: 24 MiB (2 instances) NUMA node(s): 1 NUMA node0 CPU(s): 0-19 Vulnerability Gather data sampling: Not affected Vulnerability Ghostwrite: Not affected Vulnerability Indirect target selection: Not affected Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Old microcode: Not affected Vulnerability Reg file data sampling: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; __user pointer sanitization Vulnerability Spectre v2: Mitigation; CSV2, BHB Vulnerability Srbds: Not affected Vulnerability Tsa: Not affected Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Not affected

============================== Versions of relevant libraries

[pip3] flashinfer-python==0.6.7.post3+0a7dba17.nv26.4.cu132.48455225 [pip3] numpy==2.1.0 [pip3] nvidia-cudnn-frontend==1.18.0 [pip3] nvidia-cutlass-dsl==4.5.0.dev0 [pip3] nvidia-cutlass-dsl-libs-base==4.5.0.dev0 [pip3] nvidia-ml-py==13.595.45 [pip3] pyzmq==27.1.0 [pip3] torch==2.12.0a0+0291f960b6.nv26.4.48445190 [pip3] torch_c_dlpack_ext==0.1.5 [pip3] torchaudio==2.11.0 [pip3] torchvision==0.26.0a0+48956e05.nv26.4.48445190 [pip3] transformers==4.57.6 [pip3] triton==3.6.0+git5d72932fc5.nv26.3 [conda] Could not collect

============================== vLLM Info

ROCM Version : Could not collect vLLM Version : 0.19.0+6bc3197f.nv26.04.48680843 vLLM Build Flags: CUDA Archs: 8.0 8.6 9.0 10.0 11.0 12.0+PTX; ROCm: Disabled; XPU: Disabled GPU Topology: GPU0 CPU Affinity NUMA Affinity GPU NUMA ID GPU0 X 0-19 0 N/A

Legend:

X = Self SYS = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI) NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU) PXB = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge) PIX = Connection traversing at most a single PCIe bridge NV# = Connection traversing a bonded set of # NVLinks

============================== Environment Variables

CUDA_VERSION=13.2.1.009 CUDA_DRIVER_VERSION=595.58.03 NVIDIA_REQUIRE_CUDA=cuda>=9.0 NCCL_VERSION=2.29.7 CUBLAS_VERSION=13.4.0.1 CUBLASMP_VERSION=0.8.1.2360 CUDNN_VERSION=9.21.0.82 CUDNN_FRONTEND_VERSION=1.22.1 CUDA_ARCH_LIST=8.0 8.6 9.0 10.0 11.0 12.0 LD_LIBRARY_PATH=/usr/local/lib/python3.12/dist-packages/torch/lib:/usr/local/lib/python3.12/dist-packages/torch_tensorrt/lib:/usr/local/nixlbench/lib:/usr/local/lib:/opt/amazon/efa/lib:/usr/lib:/usr/local/cuda/compat/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/nixl/lib/x86_64-linux-gnu:/usr/local/nixl/lib/aarch64-linux-gnu NVIDIA_VISIBLE_DEVICES=all NVIDIA_DRIVER_CAPABILITIES=compute,utility,video NVIDIA_PRODUCT_NAME=vLLM CUDA_COMPONENT_LIST=cccl crt nvrtc driver-dev culibos-dev cudart cudart-dev nvcc tileiras CUDA_HOME=/usr/local/cuda CUDA_HOME=/usr/local/cuda TORCH_CUDA_ARCH_LIST=8.0 8.6 9.0 10.0 11.0 12.0+PTX MAX_JOBS=12 PYTORCH_TRITON_VERSION=3.6.0+git5d72932fc5.nv26.3 NVIDIA_VLLM_VERSION=26.04 NVIDIA_BUILD_ID=299333414 PYTORCH_NVML_BASED_CUDA_CHECK=1 TORCHINDUCTOR_COMPILE_THREADS=1 TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_root


</details>


### 🐛 Describe the bug

Description
When a tool schema includes an array of objects as a parameter (e.g. questions: array<object>), the qwen3xml_tool_parser delivers the argument to clients as a JSON-encoded string instead of a native JSON array. Any client that schema-validates tool call arguments receives a type error.

The model correctly constructs the array in its reasoning trace — it understands the schema and validates it internally — but the parser fails to convert the value correctly before forwarding to the client.

Root Cause
In qwen3xml_tool_parser.py, the StreamingXMLToolCallParser._end_element method handles "deferred" parameters (array and object types) by accumulating the raw parameter text and then parsing it at </parameter> time.

The parsing is done with ast.literal_eval:

# _end_element, inside `if self.defer_current_parameter:` block
parsed_value = ast.literal_eval(raw_for_parse)
output_arguments = json.dumps(parsed_value, ensure_ascii=False)
ast.literal_eval requires Python literal syntax. Qwen3.6-27B generates standard JSON, which uses lowercase true, false, and null. These are not valid Python literals:

>>> import ast
>>> ast.literal_eval('[{"multiSelect": false}]')
# ValueError: malformed node or string on line 1
When ast.literal_eval raises, the except block runs:

except Exception:
    # Fallback: output as string as-is
    output_arguments = json.dumps(raw_text, ensure_ascii=False)
    parsed_value = raw_text
json.dumps on a plain string produces a JSON-encoded string. The client receives "questions": "\n[{...}]\n" (a string) instead of "questions": [{...}] (a native array).

This affects any parameter typed as array, arr, or sequence in the tool schema — the _preprocess_xml_chunk method sets need_defer = True for all complex types, unconditionally routing them through the ast.literal_eval path.

Steps to Reproduce
Start vLLM with --tool-call-parser qwen3_xml and any Qwen3 model, then send a request with a tool whose schema includes an array-of-objects parameter:

curl http://127.0.0.1:8001/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer none" \
  -d '{
    "model": "Qwen3.6-27B",
    "messages": [{"role":"user","content":"Ask me one question about my color preference"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "AskUserQuestion",
        "parameters": {
          "type": "object",
          "properties": {
            "questions": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "question":    {"type": "string"},
                  "header":      {"type": "string"},
                  "options":     {"type": "array", "items": {"type": "object",
                                   "properties": {"label":       {"type": "string"},
                                                  "description": {"type": "string"}}}},
                  "multiSelect": {"type": "boolean"}
                },
                "required": ["question","header","options","multiSelect"]
              }
            }
          },
          "required": ["questions"]
        }
      }
    }],
    "tool_choice": "auto"
  }' | python3 -m json.tool
Inspect choices[0].message.tool_calls[0].function.arguments in the response. The value of questions is a JSON-encoded string:

{
  "questions": "\n[{\"question\": \"What is your favorite color?\", \"header\": \"Color Preference\", \"options\": [...], \"multiSelect\": false}]\n"
}
Contrast: simple array (works correctly)
A tool with a flat array<string> parameter is not affected — ast.literal_eval succeeds on ["a", "b", "c"] because Python string lists are valid Python literals:

curl http://127.0.0.1:8001/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer none" \
  -d '{
    "model": "Qwen3.6-27B",
    "messages": [{"role":"user","content":"Call get_items with items [\"a\",\"b\",\"c\"]"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_items",
        "parameters": {
          "type": "object",
          "properties": {
            "items": {"type":"array","items":{"type":"string"}}
          },
          "required": ["items"]
        }
      }
    }],
    "tool_choice": "auto"
  }' | python3 -m json.tool
items arrives as a native array. The bug only manifests when the array contains objects whose properties include JSON-specific literals (true, false, null).

Expected Behaviour
choices[0].message.tool_calls[0].function.arguments should be:

{"questions": [{"question": "...", "header": "...", "options": [...], "multiSelect": false}]}
Actual Behaviour
choices[0].message.tool_calls[0].function.arguments is:

{"questions": "\n[{\"question\": \"...\", \"header\": \"...\", \"options\": [...], \"multiSelect\": false}]\n"}
The questions value is a string, not an array. Any schema-validating client fails with:

SchemaError(Expected array, got "\n[{...}]\n" at ["questions"])
Proposed Fix
In _end_element, inside the if self.defer_current_parameter: block, try json.loads first and fall back to ast.literal_eval only if that fails:

# Before (line ~480 in qwen3xml_tool_parser.py):
parsed_value = ast.literal_eval(raw_for_parse)
output_arguments = json.dumps(parsed_value, ensure_ascii=False)

# After:
try:
    parsed_value = json.loads(raw_for_parse.strip())
except (json.JSONDecodeError, ValueError):
    parsed_value = ast.literal_eval(raw_for_parse)
output_arguments = json.dumps(parsed_value, ensure_ascii=False)
json.loads handles true/false/null correctly. ast.literal_eval is retained as a fallback for any non-standard model output using Python-style single-quoted strings.

Verification after applying the fix
curl http://127.0.0.1:8001/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer none" \
  -d '{
    "model": "Qwen3.6-27B",
    "messages": [{"role":"user","content":"Ask me one question about my color preference"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "AskUserQuestion",
        "parameters": {
          "type": "object",
          "properties": {
            "questions": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "question":    {"type": "string"},
                  "header":      {"type": "string"},
                  "options":     {"type": "array", "items": {"type": "object",
                                   "properties": {"label":       {"type": "string"},
                                                  "description": {"type": "string"}}}},
                  "multiSelect": {"type": "boolean"}
                },
                "required": ["question","header","options","multiSelect"]
              }
            }
          },
          "required": ["questions"]
        }
      }
    }],
    "tool_choice": "auto"
  }' | python3 -c "
import sys, json
d = json.load(sys.stdin)
args = json.loads(d['choices'][0]['message']['tool_calls'][0]['function']['arguments'])
q = args['questions']
print('type:', type(q).__name__)
print('PASS' if isinstance(q, list) else 'FAIL — still a string')
"
Expected output with fix applied: type: list / PASS.

Additional Context
The same ast.literal_eval pattern appears in the related qwen3coder_tool_parser.py. That parser also has a separate security advisory ([GHSA-79j6-g2m3-jgfw](https://github.com/vllm-project/vllm/security/advisories/GHSA-79j6-g2m3-jgfw)) for using bare eval() elsewhere — the qwen3xml parser was the recommended safer alternative, but this bug still affects it.
The issue only manifests with array-of-objects parameters. Flat array<string>, array<integer>, and scalar types are unaffected because Python and JSON syntax agree on those forms.
The model's reasoning trace shows it correctly constructs the JSON and self-validates against the schema before generating the tool call — the failure is entirely in the parser's post-processing, not in model output quality.

### Before submitting a new issue...

- [x] Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the [documentation page](https://docs.vllm.ai/en/latest/), which can answer lots of frequently asked questions.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

vllm - 💡(How to fix) Fix [Bug]: qwen3xml_tool_parser: ast.literal_eval fails on JSON booleans/null, causing complex array arguments to be string-encoded instead of native arrays