Repository navigation
fix(function_call): defer partial DeepSeek non-string values - #36748
kflansburg wants to merge 3 commits into
Conversation
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, "") |
There was a problem hiding this comment.
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.
|
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: |
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_parserraises 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
string="false"parameter value. Completed earlier parameters continue to stream, and the non-string value is parsed when its closing parameter tag arrives.rstrip()calls with exact partial closing-tag suffix removal.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
pre-commit run --files python/sglang/srt/function_call/deepseekv32_detector.py test/registered/unit/function_call/test_deepseekv4_detector.pyChecklist
Review and Merge Process
CI States
Latest PR Test (Base): ❌ Run #33125928209
Latest PR Test (Extra): ❌ Run #33125927973
Latest PR Test (AMD ROCm 7.2): ❌ Run #33125928127