Skip to content

[Bugfix][Parser] Keep DeepSeek DSML tool arguments valid JSON - #59585

Draft
bojiang-li wants to merge 1 commit into
vllm-project:mainfrom
bojiang-li:bojiang-li/dsml-finite-json-20261001
Draft

bojiang-li wants to merge 1 commit into
vllm-project:mainfrom
bojiang-li:bojiang-li/dsml-finite-json-20261001

Conversation

@bojiang-li

Copy link
Copy Markdown

Overview

Keep DeepSeek DSML tool arguments valid JSON when model output contains NaN, Infinity, or overflowing exponents such as 1e999. Preserve the original parameter text instead of producing non-JSON constants or losing it as "Infinity".

Claims

  • Completed non-finite values, including values nested in arrays/objects, use the existing raw-string fallback; unfinished non-finite values wait for parameter completion.
  • Wrapper unwrapping cannot reintroduce non-finite JSON by decoding the preserved string again.
  • The shared DeepSeek V4/V3.2/V4.1 converter retains finite numbers, large integers, and quoted string values.

Validation

The 38 new regression cases fail on unchanged source and pass with this patch. They exercise the production batch and streaming parsers at several chunk boundaries, strict JSON decoding, omitted/explicit string attributes, a > inside a JSON string before the non-finite value, wrapper handling, and an exponent that overflows as more digits arrive.

python -m pytest --confcutdir=tests/parser/engine tests/parser/engine -q

Result: 5,376 passed. Existing tokenizer fixtures were used on macOS arm64 CPU; no GPU or model-inference test was run. A source-checkout version warning was present. An additional comparison against the base implementation matched all 29 existing DSML corpus samples in batch and three streaming chunk sizes (116 comparisons).

Details

Python's json.loads accepts non-finite constants and overflows large exponents to infinity; json.dumps then emits Infinity/NaN by default. Existing schema coercion does not necessarily inspect already-decoded nested containers. This reuses _is_json_finite, introduced for schema coercion in #43984, before retaining decoded DSML values and before unwrapping a decoded string wrapper. Literal fallback follows the converter's existing handling of values it cannot parse as JSON.

This is an AI-assisted draft, with source, tests, and validation prepared by agents for maintainer review.


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (Mandatory for agents, optional for humans).

  • AI assistance was used during the creation of this PR.

  • Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.

  • Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.

  • Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.

  • Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.

Signed-off-by: bojiang-li <327132355+bojiang-li@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment /ci run for upstream CI or /amd-ci run for AMD CI only whenever CI signals are needed.

Once the PR is approved or has the ready label, the PR author can also use the corresponding /ci run, /ci retry, and /ci cancel commands, or their /amd-ci variants. New commits do not start upstream CI automatically.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

@mergify mergify Bot added deepseek Related to DeepSeek models tool-calling bug Something isn't working labels Oct 1, 2026
@arpera arpera moved this to Unsorted queue in Tool Calling (arpera) Oct 15, 2026
@arpera arpera removed this from Tool Calling Oct 21, 2026

@Chebaleomkar Chebaleomkar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, focused fix. I read the diff and ran the new tests locally on CPU (Linux, Python 3.12, no GPU):

  • With the patch, tests/parser/engine/test_dsml_finite.py gives 38 passed.
  • The same test file against unpatched main gives 38 failed, so the tests do guard the fix. (I put the PR's test file on main only for this check and removed it afterwards. The failures there are expected, since main doesn't have the fix.)

What I like:

  • Falling back to the raw string for non-finite values (NaN, Infinity, overflowing exponents such as 1e999) keeps arguments valid JSON. _is_json_finite also catches nested values in arrays and objects.
  • Guarding _unwrap_wrapper_args stops unwrapping from reintroducing a non-finite value.
  • The tests cover the V4, V3.2 and V4.1 parsers, batch and several streaming chunk sizes, both string= attribute forms, a > inside a JSON string, and a partial overflow (1e99 then 1e999).

Minor points:

  • _is_json_finite is a private name imported across modules, and the tests import private helpers (_dsml_arg_converter, _test_request). A public name would be a little cleaner.
  • _is_json_finite runs json.dumps on each decoded value, including on the partial streaming path. It is probably negligible, but worth a mention.
  • The Rust frontend DSML path (#55166 touches it) may have the same non-finite behavior. It could be worth checking in a follow-up.
  • The PR is still a draft with no update since Oct 1.

I only ran the PR's tests and did not run a model end to end. AI assistance (Claude Code) was used for the code reading.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working deepseek Related to DeepSeek models tool-calling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants