Repository navigation
server: DSML tool calls stream their arguments as they are written - #2191
Merged
Merged
Conversation
ashhart
force-pushed
the
lead/dsml-stream
branch
from
November 5, 2026 01:06
13175a6 to
530e0d0
Compare
…1975) A DSML block (<|DSML|tool_calls>, V4.1's <|DSML| calls> or the grammar's <|DSML|function_calls>) used to wait for its closer and go out as one header and one arguments delta per call. tool_dsml_stream.zig now reads the block as tool_dsml.calls does, over resumed indexes: a call's header goes out once its first parameter is whole in the block's spelling and that spelling's next parameter opener or invoke closer follows, with the arguments written so far in one piece; later string values go out as JSON-escaped pieces (holding back a tail that could start a parameter, invoke or block closer), typed values as compact JSON at their closer, and the joined pieces equal the whole reply's arguments byte for byte. A block that breaks before a header goes out (an unoffered name, mixed spellings, junk, a bad flag or JSON value, a block closed with its invoke open, a value the reply never closes) still waits for its closer and parses whole, so it sends nothing, as before. A block cut by max_tokens after a header is open, so the whole reply returns the cut call as the stream sent it (#1238).
…ck that breaks early sends nothing (#1975)
ashhart
force-pushed
the
lead/dsml-stream
branch
from
November 5, 2026 02:50
530e0d0 to
3055a35
Compare
This was referenced Nov 5, 2026
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.
DeepSeek-V4 and V4.1 tool calls now stream their arguments as they are written, like GLM and XML calls already do (#1975). Before, a DSML call arrived in one piece at the block's closer, so a client saw nothing while a long file was being written.
On the issue's probe (a 2,000-character Write, fed 3 bytes at a time, host only), DSML goes from 1 argument delta at byte 2249 to 671 deltas, the first at byte 165. GLM and Qwen XML are unchanged.
When a call's header goes out. A DSML block is validated as a whole, so a header sent at the name could announce a call the whole reply then rejects, and two of #684's containment tests would fail. So the header waits until the first parameter is whole and the next tag has been written. The cost is that the first parameter's value isn't streamed:
file_pathfirst streams the large value, while a call whose first parameter is the large one sends nothing until it closes.What else changes
/v1/messagesand/v1/responsesget one delta per arguments piece. The Messages route has a test; Responses follows by construction and isn't tested end to end.stream: falsewithfinish_reason: "length", cut inside a DSML call after its header: the reply now returns the cut call as the stream sent it, as GLM and XML do, where before it kept the open block incontent.Unchanged: requests without tools,
parallel_tool_calls: false, reasoning text, XML and GLM calls, strict tools, and every block that breaks before its first header.Host tests only: no GPU, model or timing runs. The issue's measurements on DeepSeek-V4.1 hardware still need someone with the model.