vllm - ✅(Solved) Fix [Bug]: Potential misalignment between qwen3.5 chat template and recommended tool parser [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

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…
GitHub stats
vllm-project/vllm#38885Fetched 2026-04-08 02:34:24
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1

Root Cause

Qwen3 coder is fine because its chat template correctly calls tojson on all non-string arguments and converts null to "null"

PR fix notes

PR #38996: [BugFix][Parser] Fixing Qwen3.5 tool call parsing

Description (problem / solution / changelog)

fixes: #38885

Qwen3.5's chat template uses Jinja's | string filter for scalar tool-call arguments, producing Python-style "None" instead of JSON "null". The Qwen3 tool parsers only recognized "null" (case-insensitive), so "None" was passed through as a literal string, breaking tool call parsing.

The test asserts that:

  • The tool call is correctly extracted
  • Non-null params (id, label) parse normally
  • The metadata field becomes JSON null (Python None), not the string "None"

Parametrized across both Qwen3CoderToolParser and Qwen3XMLToolParser since both share the same bug.

Changed files

  • tests/tool_parsers/test_qwen3coder_tool_parser.py (modified, +57/-0)
  • vllm/tool_parsers/qwen3coder_tool_parser.py (modified, +7/-2)
  • vllm/tool_parsers/qwen3xml_tool_parser.py (modified, +34/-5)

Code Example

{%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}

---

{%- set args_value = args_value if args_value is string else args_value | tojson | safe %}
RAW_BUFFERClick to expand / collapse

Your current environment

NA

🐛 Describe the bug

Qwen3.5's chat template uses | string for scalar tool call argument values, producing Python str() representations instead of JSON literals. This breaks tool call parsing at inference time for models fine-tuned using this chat template.

Qwen3.5 chat template:

{%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}

Only mappings and non-string sequences get tojson. Other types like None go through | string gets converted to "None". So, the model trained on this chat template would emit "None" instead of "null".

VLLM recommends qwen3 coder tool parser which can only parse string "null" but not "None".

Qwen3 coder is fine because its chat template correctly calls tojson on all non-string arguments and converts null to "null"

{%- set args_value = args_value if args_value is string else args_value | tojson | safe %}

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

extent analysis

TL;DR

Update the Qwen3.5 chat template to use tojson for all non-string argument values, ensuring JSON literals are produced instead of Python str() representations.

Guidance

  • Identify the current Qwen3.5 chat template and update the line {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %} to {%- set args_value = args_value if args_value is string else args_value | tojson | safe %} to correctly handle all non-string arguments.
  • Verify that the updated template produces the expected JSON literals for all argument types, including None which should be converted to "null".
  • Test the updated template with the VLLM tool parser to ensure it can correctly parse the output.
  • Review other chat templates for similar issues to prevent future problems.

Example

The corrected Qwen3.5 chat template should resemble the Qwen3 coder chat template:

{%- set args_value = args_value if args_value is string else args_value | tojson | safe %}

Notes

This fix assumes that the tojson filter is correctly configured to produce JSON literals for all argument types. If issues persist, further investigation into the tojson filter or the VLLM tool parser may be necessary.

Recommendation

Apply the workaround by updating the Qwen3.5 chat template to use the corrected tojson handling, as this should resolve the issue with the VLLM tool parser.

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