fix: strip DeepSeek DSML tool-call markers from assistant content - #805
Open
sharadvc wants to merge 1 commit into
Open
fix: strip DeepSeek DSML tool-call markers from assistant content#805sharadvc wants to merge 1 commit into
sharadvc wants to merge 1 commit into
Conversation
DeepSeek's DSML protocol injects tool-call routing markers (e.g. <‖DSML‖tool_calls>, <‖DSML‖invoke ...>) into the content stream before the actual tool_calls delta arrives. These markers leak into the UI when tool calls fail or are not parsed in time. This adds _strip_dsml_markers() — a fast regex filter applied to every content chunk yielded by _parse_openai_sse(). The guard short-circuits on chunks that don't contain 'DSML' so there is zero overhead on non-DeepSeek streams. Closes lsdefine#804
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DeepSeek's DSML protocol injects tool-call routing markers into the content stream before the actual
tool_callsdelta arrives. These markers (e.g.<‖DSML‖tool_calls>,<‖DSML‖invoke ...>) leak into the UI when tool calls fail or aren't parsed in time.Fix
Adds
_strip_dsml_markers()— a fast regex filter applied to every content chunk yielded by_parse_openai_sse().'DSML'‖, Unicode|, ASCII pipe|, and double-escaped formsTesting
<‖DSML‖tool_calls>,<‖DSML‖invoke name="ShellCommand" arguments="{...}">— all stripped cleanlyCloses #804