Skip to content

fix(function_call): defer partial DeepSeek non-string values - #36748

Closed
kflansburg wants to merge 3 commits into
sgl-project:mainfrom
kflansburg:kflansburg/fix-dsv4-stable-nonstring-arguments
Closed

kflansburg wants to merge 3 commits into
sgl-project:mainfrom
kflansburg:kflansburg/fix-dsv4-stable-nonstring-arguments

Conversation

@kflansburg

@kflansburg kflansburg commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

DeepSeek V3.2/V4 streaming tool parsing can expose raw DSML text when an incomplete non-string parameter contains mismatched JSON delimiters. partial_json_parser raises during the partial scan, and the detector fallback returns its DSML buffer as normal assistant content.

This is a narrower alternative to #36339. It fixes the failing non-string path without changing the existing provisional streaming behavior for direct JSON or string="true" parameters.

Modifications

  • Do not parse or emit an incomplete string="false" parameter value. Completed earlier parameters continue to stream, and the non-string value is parsed when its closing parameter tag arrives.
  • Replace character-set rstrip() calls with exact partial closing-tag suffix removal.
  • Preserve current behavior for malformed outer DSML and duplicate parameter names.
  • Add regression and compatibility tests, including every fixed chunk width for the observed assertion shapes.

Accuracy Tests

Not applicable. This changes response parsing only, not model forward output. Streaming and non-streaming arguments match for valid nested arrays and malformed non-string values that fall back to strings.

Speed Tests and Profiling

No inference-path impact. The change removes repeated partial JSON parsing for incomplete non-string parameters. Those argument fragments are delayed until the parameter closes; direct JSON and string parameters retain their existing streaming behavior.

Tests

  • Confirmed the new regression tests fail against the existing parser with mismatched array/object delimiter assertions.
  • Swept every fixed chunk width for both failing values using production dependency versions.
  • Verified valid nested arrays, malformed non-string fallback, incomplete outer DSML, duplicate parameters, and partial closing-tag suffixes.
  • pre-commit run --files python/sglang/srt/function_call/deepseekv32_detector.py test/registered/unit/function_call/test_deepseekv4_detector.py
  • Python compilation passed for both changed files.

Checklist

  • Format your code according to the pre-commit guidance.
  • Add unit tests.
  • Update documentation. No user-facing behavior or option changed.
  • Provide accuracy and speed impact.
  • Follow the SGLang code style guidance.

Review and Merge Process

  1. Ping Merge Oncalls to start the process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests.
  4. After green CI and required approvals, ask Merge Oncalls to merge.

CI States

Latest PR Test (Base): ❌ Run #33125928209
Latest PR Test (Extra): ❌ Run #33125927973
Latest PR Test (AMD ROCm 7.2): ❌ Run #33125928127

agent added 3 commits August 27, 2026 16:03
Incomplete non-string DSML parameters can change representation or raise while partial_json_parser scans mismatched delimiters. Do not emit their provisional value before the parameter closes.

Replace character-set rstrip calls with exact partial-tag suffix removal. Existing direct JSON, string parameters, malformed outer DSML, and duplicate-parameter behavior remain unchanged.

Accuracy: no model output changes. Speed: removes partial JSON parsing for incomplete non-string parameters. Tests: production-runtime sweep over all chunk widths plus compatibility cases; pre-commit.
Cover mismatched non-string delimiters, exact partial-tag trimming, and compatibility for malformed outer DSML and duplicate parameter names.
Verify malformed non-string values match non-streaming output at every fixed chunk width.
normal += result.normal_text
calls.extend(result.calls)

self.assertEqual(normal, "")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The registered parser suite still fails on separator whitespace and obsolete tool-call chunk counts. Consider checking reconstructed arguments and protocol leakage without requiring exact whitespace or fragmentation.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks @kflansburg. Closing this because you have 6 PRs open and none updated in 7 days, over our soft cap of 5 for idle PRs.

Reopen the two or three you most want reviewed - a short active set moves faster than a long idle one.

Some directories moved recently, so an older branch may need retargeting:
sgl-kernel/ -> python/sglang/kernels/aot/, python/sglang/jit_kernel/
-> python/sglang/kernels/jit/, docs/ -> docs/docs/ (.mdx),
bench_serving.py -> benchmark/serving.py, test/srt/ -> test/registered/.

@github-actions github-actions Bot closed this Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants