Conversation
DeepSeekV3Parser.parse_streaming_increment removes every "```" from a delta that carries no tool-call markup, so a streamed answer containing a fenced code block loses its fences while detect_and_parse returns the same text intact. The fence is only part of the tool-call syntax inside a <|tool▁call▁begin|> ... <|tool▁call▁end|> block, which this branch never sees. Strip only the closing tokens, as DeepSeekV31Parser does. Signed-off-by: Yiğit ERDOĞAN <yigiterdogan023@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. WalkthroughThe DeepSeek V3 streaming parser no longer removes standalone Markdown code fences from normal text. Parameterized tests verify fence preservation across DeepSeek V3, V3.1, V3.2, and V4 parsers. ChangesDeepSeek fence preservation
Priority: ➖ Normal Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk remains in the reviewed change. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Description
Fixes #19225.
When a streamed delta carries no tool-call markup,
DeepSeekV3Parser.parse_streaming_incrementflushes it as content after stripping the closing tokens. The list it strips also contains
the markdown fence, so every fenced code block in a streamed answer loses its fences while
detect_and_parsereturns the same text intact:The fence is part of the tool-call syntax only inside a
<|tool▁call▁begin|> ... <|tool▁call▁end|>block. This branch is reached only when nostart token is present in the buffer, so the text it sees is model content. A completed
call is removed from the buffer together with its fences (
deepseekv3_parser.py:188-194),so nothing from the markup can reach this branch either.
The change drops
"```"from the list, leaving the two closing tokens. That is exactly whatthe sibling
DeepSeekV31Parserdoes on the same path (deepseekv31_parser.py:109), andthe DSML parsers (
deepseek_v32,deepseek_v4) also stream such text verbatim, sodeepseek_v3was the only parser in the package that altered content here. There is noAPI change and no change to the non-streaming path.
Test Coverage
tests/unittest/llmapi/apps/test_tool_parsers.py, already registered ascpu_onlyintests/integration/test_lists/test-db/l0_cpu.yml:test_deepseek_streaming_keeps_markdown_fences— 4 parametrizations, one per DeepSeekparser class. Each streams a fenced code block as a single delta and asserts the content
comes back verbatim and equal to what
detect_and_parsereturns for the same string.The V3 case fails on
main; the other three pin the sibling parsers so the strip is notreintroduced there.
Runtime on this box, measured over 2000 repetitions each: 9.7/12.0/25.6/24.2 us, 0.071 ms
for all four together. The file's full suite is otherwise unchanged: 351 passed locally
versus 347 before, with an identical set of 50 pre-existing failures that need the full
openai_protocol/postprocess_handlersimport chain, which this machine cannot load.PR Checklist
[#issue][type] descriptionmainand green here@tongyuantongyu this is the same no-tool-call branch of
deepseekv3_parser.pythat #17573and #17903 touched, one line in the strip list. Would you mind taking a look and triggering
the pipeline when you have a moment?
Dev Engineer Review
DeepSeekV3Parser.parse_streaming_incrementnow removes only tool-call closing tokens from normal streamed content. Markdown fences remain unchanged.detect_and_parsepath and public APIs remain unchanged.DeepSeekV31Parserbehavior and limits regression risk to the affected streaming path.QA Engineer Review
tests/unittest/llmapi/apps/test_tool_parsers.pywith a parameterized regression test for DeepSeek parser classes.Per-File QA Perspective
tensorrt_llm/serve/tool_parser/deepseekv3_parser.py: Verify that streamed normal content preserves Markdown fences while tool-call closing tokens remain filtered. Confirm completed tool calls anddetect_and_parsebehavior remain unchanged.tests/unittest/llmapi/apps/test_tool_parsers.py: Covers the streaming/non-streaming equivalence regression across the DeepSeek parser classes. No test-list change is reported.