Skip to content

[None][fix] DeepSeek DSML tool parsers: keep string parameter values as written - #21025

Merged
lori-ren merged 1 commit into
NVIDIA:mainfrom
JunyiXu-nv:dev-junyix-fix-dsml-parameter-values
Oct 27, 2026
Merged

lori-ren merged 1 commit into
NVIDIA:mainfrom
JunyiXu-nv:dev-junyix-fix-dsml-parameter-values

Conversation

@JunyiXu-nv

@JunyiXu-nv JunyiXu-nv commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Description

The DeepSeek V3.2, V4 and V4.1 encoders render a string parameter value verbatim between its tags (<|DSML|parameter name="..." string="true">value</|DSML|parameter>). The tool instructions they render tell the model to write string values as is. The DSML parser the three share called .strip() on every string value, so:

  • an edit's old_string and new_string lost their leading indentation;
  • a written file lost its final newline;
  • a command lost its trailing space.

The client then ran a call other than the one the model wrote. The history it sent back also rendered differently from what the model had generated.

A string value is now taken as written. JSON values (string="false") are parsed as before; json.loads already ignores the whitespace around them.

Test Coverage

tests/unittest/llmapi/apps/test_tool_parsers.py (CPU, already in l0_cpu.yml) gains test_dsml_string_parameter_values_are_kept_as_written.

  • It covers the V3.2, V4 and V4.1 formats, each non-streaming and streaming in 7-character chunks.
  • A value with leading indentation and an inner newline, and a value ending in a newline, must come back exactly.
  • On main all 6 cases fail by assertion; with the change they pass.
  • The full tool-parser suite and the Anthropic adapter and route suites pass: 983 tests, on a build of main 9bb7931 with this change and the other open serving fixes applied.

A property-based check backs the example.

  • Tool calls with generated arguments were rendered with the server's own V4.1 renderer (tensorrt_llm/tokenizer/deepseek_v41/tokenizer.py). The arguments were string values with whitespace at either end, and JSON values.
  • They were parsed back non-streaming, and streaming at random chunk boundaries. All 500 generated cases came back exactly.
  • Six planted bugs were each caught: stripping either end or both, dropping a final newline, a parameter regex that swallows the edge whitespace, and JSON values kept as strings.

End to end, DeepSeek-V4.1-Flash served Claude Code coding sessions over /v1/messages. What the model wrote (--post_processor_hook) was compared with what was delivered.

  • Before, in 8 sessions, all 72 string arguments the model wrote with whitespace at an edge were delivered stripped:

    • 41 Write contents lost their final newline;
    • 14 Edit calls lost the indentation of old_string and new_string;
    • 3 Bash commands lost a trailing space.

    The other 1,545 string arguments came through verbatim.

  • After, in 5 sessions, all 1,000 string arguments were delivered as written, 63 of them with edge whitespace.

PR Checklist

  • PR description clearly explains what and why.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

🤖 Generated with Claude Code

Dev Engineer Review

DeepSeekV32Parser._parse_parameters_from_xml now returns string="true" values without trimming their contents. Non-string parameter parsing still strips whitespace before JSON decoding and fallback. The scope is limited to shared DSML string-value handling. No current review findings or severity counts were supplied.

QA Engineer Review

Modified tests/unittest/llmapi/apps/test_tool_parsers.py. The new test_dsml_string_parameter_values_are_kept_as_written test checks DeepSeek V3.2, V4, and V4.1 in one-shot and streaming modes. It verifies indentation, embedded newlines, and a trailing newline in string values. The test file is listed in tests/integration/test_lists/test-db/l0_cpu.yml. No manual-QA list entry was found in the supplied search results. Coverage verdict: sufficient for the stated whitespace-preservation behavior. Test execution results were not independently verified.

Per-File QA Perspective

  • tensorrt_llm/serve/tool_parser/deepseekv32_parser.py — Verify that DSML string values retain leading and trailing whitespace, while non-string values and direct JSON parsing retain their existing behavior.
  • tests/unittest/llmapi/apps/test_tool_parsers.py — Adds one parameterized test across three parser formats and streaming/non-streaming modes. The test file is listed in the CI test database at tests/integration/test_lists/test-db/l0_cpu.yml.

…as written

The DeepSeek V3.2, V4 and V4.1 encoders render a string parameter value
verbatim between its tags, and tell the model to write string values as
is. The parser stripped the value, so an edit's old_string lost its
indentation and a written file lost its last newline.

A string value is now taken as written. JSON values are parsed as before.

Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0113164 and 09c04ce.

Files selected for processing: 2
  • tensorrt_llm/serve/tool_parser/deepseekv32_parser.py
  • tests/unittest/llmapi/apps/test_tool_parsers.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Walkthrough

DeepSeek DSML parsing now preserves whitespace in string parameter values. Tests cover one-shot and 7-character-chunk parsing for DeepSeek V3.2, V4, and V4.1.

Changes

DeepSeek DSML string parameter parsing

Layer / File(s) Summary
Preserve string parameter whitespace
tensorrt_llm/serve/tool_parser/deepseekv32_parser.py, tests/unittest/llmapi/apps/test_tool_parsers.py
String parameters are stored without trimming. Tests check that V3.2, V4, and V4.1 preserve indentation, embedded newlines, and a trailing newline in one-shot and streaming parses.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • NVIDIA/TensorRT-LLM#20873: Both changes define how the DeepSeek DSML parser handles whitespace, distinguishing string content from structural layout.
Merge Risk: Minimal · up to 09c04

The change preserves DeepSeek string argument whitespace, with regression coverage across the three affected parsers. No actionable merge risk is established.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the DeepSeek DSML parser fix and states the key behavior change: preserving string parameter values as written.
Description check Passed The description explains the issue, solution, affected parser versions, regression tests, broader validation, and observed impact. It includes the required Description and Test Coverage sections. The …
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the issue, solution, affected parser versions, regression tests, broader validation, and observed impact. It includes the required Description and Test Coverage sections. The checklist is only partially completed, but the missing checks are non-critical for this assessment.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@JunyiXu-nv

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #80634 [ run ] triggered by Bot. Commit: 09c04ce Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #80634 [ run ] completed with state SUCCESS. Commit: 09c04ce
/LLM/main/L0_MergeRequest_PR pipeline #66386 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@JunyiXu-nv

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #80688 [ run ] triggered by Bot. Commit: 09c04ce Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #80688 [ run ] completed with state SUCCESS. Commit: 09c04ce
/LLM/main/L0_MergeRequest_PR pipeline #66437 completed with status: 'SUCCESS'

CI Report

Link to invocation

@lori-ren
lori-ren merged commit 38d2c3a into NVIDIA:main Oct 27, 2026
13 checks passed
@github-actions

Copy link
Copy Markdown

Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants