Skip to content

vllm.parser.qwen3

Qwen3 parser for tool calls and reasoning.

Qwen3 XML tool call format::

<tool_call>
<function=func_name>
<parameter=key>value</parameter>
</function>
</tool_call>

The argument body consists of <parameter=NAME>VALUE</parameter> tags. The _qwen3_arg_converter parses these into a JSON object.

Classes:

  • Qwen3Parser –

    Qwen3 parser: <think>/</think> reasoning +

Qwen3Parser

Bases: ParserEngine

Qwen3 parser: <think>/</think> reasoning + <tool_call> XML tool calls in a single engine.

  • <tool_call> as implicit reasoning end (a grammar transition, so it also feeds is_reasoning_end and the structured-output gate)

Subclasses that share the grammar but differ only in the four wrapper token strings (reasoning + tool-call) override the class attributes below; everything else is inherited unchanged.

_ClosedParams

Closed parameters of a raw argument text, reused by longer texts.

Raw arguments only grow while a call streams, so a parse of a text that extends text resumes after its last closed parameter.

_param_value_end_window(text)

Return the suffix of text that may still grow into a value end.

_param_value_extender(raw_args, trim_newlines, closed=None)

Extend the open trailing <parameter=...> value of raw_args.

The extender streams exactly what the converter would for the same text. With trim_newlines it follows _trim_wrapping_newlines: it drops a leading newline of the value and holds back a trailing one.

_qwen3_parse_params(raw_args, partial, closed=None)

Return the closed parameters, trimmed, and the open trailing one.

_trim_wrapping_newlines(value)

Strip one leading and one trailing newline (the Qwen3 template markup).