Skip to content

[Bug]: DeepSeek V4 DSML tool parser mishandles wrapped and reserved arguments #41240

Description

@QwertyJack

Current behavior

vLLM already has registered deepseek_v4 tokenizer, tool-call parser, and reasoning parser support. Recent upstream work also added structural-tag support and generic DSV3.2/V4 non-streaming type conversion.

There are still DeepSeek V4 DSML tool-call edge cases that do not round-trip OpenAI-compatible tool arguments correctly with the serving flag combination:

--tokenizer-mode deepseek_v4 \
--tool-call-parser deepseek_v4 \
--enable-auto-tool-choice \
--reasoning-parser deepseek_v4

Problems

The remaining parser/tokenizer gaps are:

  • DSML parameter parsing should respect the string="true|false" attribute and use the request tool schema / JSON fallback for non-string values
  • model-emitted single arguments or input wrapper parameters should be unwrapped when those names are not actual fields in the requested tool schema
  • real tool schema parameters named arguments should not be confused with OpenAI tool-call wrapper semantics
  • streaming responses that end while plain text is being held because it looks like the start of a DSML marker, for example 2 <, should flush that text

Expected behavior

The DeepSeek V4 tokenizer/parser path should:

  • preserve literal strings when DSML emits string="true", and coerce string="false" values through the relevant schema or JSON parsing
  • unwrap single arguments / input wrapper objects only when the wrapper is not a real schema field and the wrapped object matches the schema fields
  • safely render and parse tool schemas/history containing a real parameter named arguments
  • flush held plain text at the end of a stream when no DSML tool call actually follows

Notes

This issue is about DeepSeek V4 DSML tool-call parser/tokenizer correctness. It does not require adding the deepseek_v4 parser from scratch, since that parser is already present upstream.

DeepSeek's official top-level thinking={"type": "enabled"|"disabled"} request shape is a related API-compatibility topic, but per review feedback it is not part of the current fix. vLLM users should continue to use chat_template_kwargs for DeepSeek V4 thinking toggles, matching the vLLM DeepSeek V4 recipe.

Upstream #41198 partially overlaps by adding generic DSV3.2/V4 type conversion for non-streaming tool calls. The remaining issue is narrower: V4 DSML string-attribute handling, wrapper repair, real arguments field escaping, and streaming final flush behavior.

Related PR

Proposed fix: #41241

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions