Case file — PR #685 "fix(frontend): stream DeepSeek tool-call arguments"
Author peperunas · base main · head 2f0ed9d3da704143b8437eb40e49fd451bb875e0 (2f0ed9d), branch fix/dsml-tool-call-streaming · 13 files, +662/−72 · open, ready for review, no labels, no CI checks, no reviews, no comments · opened 2026-12-02 18:07, updated 2026-12-02 18:07.
Key findings
- A second, universal behaviour change hides behind the streaming fix.
Accumulator::finish(cause)andResponseOutput::finish(cause)now drop an announced-but-unfinished tool call for every termination other thanEos(helios/src/server/output.rs:163-173, newpub(crate) fn drops_unfinished_call(cause) -> bool { cause != Termination::Eos }atoutput.rs:478-480, andoutput.rs:1730-1742for the Messages/Responses block emitter). Onmain, the same situation returnedErr("incomplete emitted tool call"), i.e. a request error. This affects all tool parsers and all three wire protocols, while the streaming win affects DSML only. - It inverts an existing test that asserted the opposite.
user_stop_cannot_retract_an_already_emitted_partial_tool_callon main becomesuser_stop_omits_an_already_emitted_partial_tool_call(helios/src/server/output.rs:1265-1274), now assertingpresentation.finish(Termination::UserStop)succeeds andmessage().tool_callsis absent. The old test's name ("cannot retract") shows the earlier behaviour was deliberate. The description mentions the new behaviour in one clause but never says it replaces an error with success. - It reverses #364's deliberate "check the size bound before emitting any tool event" property. #364 (voipmonitor, merged 2026-11-19, reviewed by yatesdr) moved the 1 MiB check ahead of the first tool event. #685 publishes fragments then runs
check_sizeon the next append (dsml.rs:191-192), and says so in the docs: "The bound is enforced on the append that crosses it, after the call name and earlier argument fragments were published and are not retracted" (docs/api.md:570-572). Transparent, but it undoes another author's reviewed invariant. - The buffering was documented behaviour, not an undocumented bug.
docs/api.md:540-541on main read: "The model parsers buffer tool envelopes until they are complete, so argument events do not imply incremental generation of an unfinished call." #685 deletes that sentence and replaces it with the per-parser description (docs/api.md:540-555). No issue, roadmap item, or maintainer request asks for streaming tool arguments (see "The why"). - No independent evidence. No CI checks on the head commit, no reviews, no comments, and unlike neighbouring PRs (#573, #670) no flare-autobot review has run. Every number is self-reported local/release test output plus one measurement against the author's own deployment.
The change
What it does, in plain terms: the DSML (DeepSeek) parser used to hold a whole tool call privately and hand it to the encoder in one burst when the closing tag arrived. Now the parser announces the call as soon as its name completes and pushes out argument bytes as they accumulate, so the client sees the function name early and function.arguments deltas through the generation.
Verified mechanics (helios/src/output/dsml.rs):
Callgainspublished_argument_bytes(dsml.rs:38) andpublish(index, events)(dsml.rs:49-62), which pushesEvent::ToolArguments{ index, text: arguments[published..] }and advances the cursor; it is a no-op whileliteral.is_some()— astring="false"value may still be rewritten byclose_literal(dsml.rs:64-78), so no published byte changes later.Event::ToolBegin { index: self.calls, name, id: None }moved fromToolCallArgumentsEndtoToolNameEnd(dsml.rs:145-156);id: Nonemeans the id is still synthesized downstream.- Each
ToolCallArgumentsTextaction doescheck_size()?; publish(...)(dsml.rs:173-193); label bytes are appended byLabelToolCallArgumentsand travel with the next text fragment or the end (dsml.rs:157-172). ToolCallArgumentsEnddoesclose_literal(), appendsclosing_text,check_size()?,validate_arguments()?,publish(), thenEvent::ToolEnd{index}andself.calls += 1(dsml.rs:194-206). Note the order: a call that fails validation fails after its fragments were published.- Strict tools (
self.strict_tools,dsml.rs:147) are unchanged, andEncoder::apply'spending_strict_callsparking still suppresses frames until schema validation (helios/src/server/protocol/encode.rs:564-621). That part of the description checks out.
Size: one substantive file (dsml.rs, +315/−18) plus a second substantive change in helios/src/server/output.rs (+33/−19) and encode.rs (+2/−2); helios/src/server/protocol/tests.rs +266/−0 is new tests; docs/api.md +25/−12. The other eight files (argument_tags.rs, chatml.rs, gemma_call.rs (not opened), minimax_xml.rs (not opened), pipeline.rs, xtml.rs, runtime_core/protobuf.rs, server/runtime/phase_tests.rs (not opened)) are mechanical finish() → finish(Termination::X) call-site updates.
What the change does that the description does not say
- Truncation no longer errors. See Key finding 1/2.
Encoder::finishmaps the cause (encode.rs:658-677) and then picks the finish reason fromhas_tools()on the popped accumulator, so a header-only truncated call yields"stop"(encode.rs:690-696);tool_choice: requiredstill errors if no completed call exists (encode.rs:685-689). - A rejected argument object now follows published fragments.
validate_argumentsruns at end (dsml.rs:202), so a client sees partial argument JSON and then aserver_error; there is a new test for exactly this. Previously nothing was published on that path. string="false"values are withheld per parameter, not just per byte — the streaming benefit is reduced for non-string parameters (dsml.rs:54). Not stated in the description.- The 1 MiB bound now trips after publication (Key finding 3), which the description does not frame as a reversal of #364.
drops_unfinished_callis a shared predicate onTermination, not a per-dialect flag — consistent with the charter's no-per-model-branch rule (#267, #334).
What the description says that the change does not do
- The description's test counts have moved between the orientation packet's copy and the live body (1783 passed/18 failed with 12 engram failures → 1787/16 with ten;
output::111 → 113;server::protocol94 → 96) while the head commit id stayed2f0ed9d. Either the body was edited or the packet snapshot predated a push; the flaky-engram claim is what shifts, so it reads as a body edit. Nothing in the diff contradicts any other description claim: the tagged parsers still buffer (verified —DsmlOutputis the only parser changed semantically),flare/flare-cliare not built, and the tagged dialects are not exercised live.
The why
- The stated problem:
DsmlOutputcollected the pinneddeepseek-recipeparser's per-fragment actions and emitted begin/arguments/end together atToolCallArgumentsEnd, so "a client received nothing between the tool name and the finished argument object: a multi-kilobytewriteargument left the stream silent for the whole generation". - No issue asks for this. Searches across open and recently closed items for streaming/incremental tool arguments, DSML arguments, stalled streams, "buffer tool envelopes", "incomplete emitted tool call partial" produced only #685 itself. The only pre-existing statement of the behaviour is
docs/api.md:540-541on main, which documented it as the contract. - Adjacent reports, none of them this bug: #133 (closed) GLM-5.3 live-serving trace, whose thread discusses truncated tool envelopes on the wire; #319 (closed) engine wedges under agent traffic, attributed to scheduling/cancellation; #679 (open, ktsaou) output-layer stream failures counted as cancellations (metrics, adjacent); #347 (open) umbrella for GLM-5.3 production agent traffic — its body could not be retrieved (the reading tool refused: "the arguments are not valid JSON for this tool"), so whether it lists this defect is unknown.
- Age/demand: the motivation is the author's own observation on
https://llm.giugl.ioservingpino/chat(DeepSeek-V4.1-Flash-1017), the same day the PR was opened. There is no accumulated demand (no 👍, no duplicate reports, no agent-loop consumer filing it).
Related work
| Item | Relation |
|---|---|
| #364 (merged, voipmonitor, reviewed by yatesdr) "Enforce DeepSeek tool call size and retain deeply nested values" | Reversed in part. #364 moved the 1 MiB check to before the first tool event; #685 publishes first and documents that the bound trips afterwards (docs/api.md:570-572). |
| #359 (merged, voipmonitor) retain DeepSeek tool values that are not valid JSON | Built on. Source of literal/literal_quoted/literal_escaped and close_literal; publish() explicitly defers while a literal may be rewritten (dsml.rs:49-62). |
| #418 (merged, jcartu) strict function-tool schemas for DSML, Qwen, GLM, TML | Built on / preserved. pending_strict_calls parking in encode.rs:564-621 is untouched; #685 adds tests that strict calls still emit nothing early. |
| #333 (merged, yatesdr) complete responses after one tool call when parallel calls are disabled | Built on. It routes the discarded second call as Termination::Cancelled (encode.rs:666); #685's new "Cancelled drops the announced call" path sits on that. |
| #577 (open) Chat reasoning aliases + allow literal closing tool tags in argument values | Complementary; touches argument_tags/chatml/gemma_call/minimax_xml — the parsers #685 leaves buffering. Rebase overlap is mechanical. |
#575 (open) preserve raw JSON tool arguments in TmlOutput |
Same family of byte-faithfulness concern, other dialect. |
#578 (merged) bump deepseek-recipe for aborted DSML parameter openers |
The pinned dependency whose action stream #685 consumes; no bump needed here. |
| #670 (merged 2026-12-02, lukealonso) THINK_TAGS + TAGGED_JSON | Shares eight files including dsml.rs, docs/api.md, protocol/tests.rs, phase_tests.rs (not opened); landed hours after #685 branched (1fbcc3c). |
| #418's evidence, which cites an output-limit sweep with "zero leaked partial calls" | The guarantee #685's truncation change reinterprets — worth re-reading when judging whether partial calls are supposed to leak. |
#102 (merged) ignore_eos finish-reason classification |
Adjacent finish-reason territory; a reviewer there noted a partial tool call can stay in the message while the reason changes. |
Recent activity
dsml.rswas actively edited in the three weeks before #685 — #418 strict (0b09434d, 2026-11-22), hardening (dc0d40e0, 2026-11-19), #359/#364 (c96ed096,89054cb3,401b7e0c, 2026-11-18), #228 (f76b517f), #167 (902c88e2), #162 (5dd6723e) — overwhelmingly by voipmonitor (Martin Vit). #685 threads through exactly that machinery.server/output.rs:4ed5d875(#637, 2026-11-30),0794d5b8(#170),902c88e2(#167),a5b6ed26(#67); the Accumulator/ResponseOutput/Encoder skeleton is Luke Alonso's (bcd6b249,6f7a45bd,99cfcd5b, Oct 13-14). TheUserStop/partial-call behaviour #685 flips descends from that skeleton period.- #670 (2acc3f3a, 2026-12-02 14:16) and #660 (4cc6f2fd) merged to main after #685's branch point; #670 touched eight of #685's 13 files including a rewrite of the same
docs/api.mdparser section, so a rebase is required before merge and the api.md resolution is not trivial. - Nothing found on main that conflicts semantically with the streaming change; the tension is with #364/#333-adjacent invariants, as above.
People
- peperunas (commit author line: Giulio De Pasquale), GitHub association FIRST_TIME_CONTRIBUTOR. Last 180 days: 0 merged, 1 closed (#519 "fix(helios): park an Engram gather while it waits for device-published ids", 2026-11-25 — unmerged). Discord: peperunas (repo convention: each PR body ends with a Discord line, cf. #364 "Discord: festr", #670 "Discord: lukealonso").
- Area owners:
helios/srclast 180 days — Luke Alonso (237 commits), Martin Vit/voipmonitor (52), yatesdr (49).dsml.rsspecifically: Luke Alonso (a7af975eofficial DeepSeek adapter), voipmonitor (#359, #364, several commits), jcartu (#418), yatesdr (#167, #333), brandonmmusic-max (#162, #577).server/output.rs/encode.rs: yatesdr, flare-autobot (#637), mark-yong. - Charter priority contributors: @voipmonitor, @original-el8, @lukealonso. The two natural reviewers for #685 are voipmonitor (whose #364 invariant is reversed) and yatesdr (who approved it and authored the
UserStop/Cancelled paths). Neither has engaged. - The author edited the PR body after opening (test counts, and wording of the streaming sentence changed; head unchanged) — worth knowing when comparing description to diff.
Community
- Zero:
pr_comments→ "No comments";read_item(685)→ "Discussion (0)"; no reviews, no inline comments, no labels, no reactions readable. - Comparison: comparable output-layer PRs draw traffic fast — #573 got a flare-autobot case file ~1.5 h after opening and a full Autobot Review before merge; #670 got an intake notice 24 min after opening and "Changes Requested" with 3 blockers 13 min later; #364 got a substantive human review from yatesdr within 10 minutes. So the silence on #685 after hours reflects that the automated review pipeline has not been triggered for this PR, not that it was screened out.
- No downstream agent-loop or SDK consumer has spoken up in the tracker about the silent-tool-call symptom.
Project fit
Aligns:
- Charter vision names "coding agents, and heavy tool use"; a stalled tool-call stream is precisely that workload's failure mode.
- "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)" — #685 fixes when the parser publishes rather than papering over it.
- "PR descriptions: expect four parts — why, what changed, claimed result, evidence" — #685 has all four and is unusually explicit about what was not tested.
- The evidence is served-workload measurement (566 frames, 2196 bytes, hash equal to non-streaming), the kind the charter asks for, though self-reported and single-model.
Tensions:
- "What gets merged" wants a maintainer request, roadmap item, reproducible bug, measured performance/memory issue, or bad docs. #685 is closest to "reproducible bug" + "measured" but the bug was never filed and no maintainer asked. This is the largest fit risk.
- "Keep the runtime small and model-agnostic… shouldn't accumulate per-model branches (#267, #334)": no new shared-layer branch is added, but the PR makes the streaming guarantee explicitly dialect-dependent (DSML streams; the tagged parsers do not) and now documents that split (
docs/api.md:540-555). A reviewer could call it two behaviours behind oneEventcontract. - Code-review standards ask to check interactions across supported configurations and to verify existing artefacts load. The author did not build
flareorflare-cli; the signature changes are crate-internal (Accumulatorispub(crate),ResponseOutput::finishispub fnbut consumed only inencode.rs:677), so the risk is low but unverified. No roadmap item covers tool-call streaming.
Claims and evidence
| Claim | Backing |
|---|---|
| Tool name arrives at header completion; arguments arrive incrementally | Code: dsml.rs:145-156, 173-206; new tests in protocol/tests.rs (+266) including a full OutputPipeline → Chat encoder round-trip reassembling >2 pre-close frames. |
| Fragments concatenate to stored arguments byte for byte | publish() cursor (dsml.rs:49-62) plus tests at every UTF-8 split; literal deferral prevents rewrite-after-publish. Verified in code. |
| Truncated output-limit/stop-string/cancel calls keep fragments, are omitted from buffered body | Code output.rs:163-173,478-480,1730-1742, encode.rs:658-677; new Chat/Messages/Responses truncation tests. |
| Strict tools still emit no frame before schema acceptance | encode.rs:564-621 untouched; dsml.rs:147 unchanged. Verified. |
1787 passed / 16 failed, six need FLARE_TEST_TEMPLATE_DIR, ten engram tests flaky and failing identically on unmodified main |
Self-reported; count changed from 1783/18 between packet and live body; no CI run to corroborate; flakiness claim untestable here. |
| Live: 566 argument frames / 2196 bytes hashing identical to non-streaming, previously 2 frames for 2.2 KB | Self-reported, one model (pino/chat, DeepSeek-V4.1-Flash-1017), one request, author's own endpoint; no logs or harness reproduced here. |
Tagged dialects still buffer; tagged dialects not exercised live; flare/flare-cli not built |
Admitted in the description and consistent with the diff (only dsml.rs changes semantics). |
No claim in the description is contradicted by the diff; the gap is that the description does not present the truncation change as the reversal it is, nor the #364 bound reversal.
Reach
- Clients (all three protocols): DSML tool calls stream; chat-completions
function.arguments, Messagesinput_json_delta, Responses argument deltas. Any client that relied on main's documented "argument events do not imply incremental generation" (docs/api.md:540-541) must now tolerate partial JSON deltas — which is the normal OpenAI SDK contract, so most clients improve (stall watchdogs stop firing). - Truncation semantics (universal): a request that previously failed with
server_error"incomplete emitted tool call" after a stop string,UserStop, cancellation orExecutionErrormid-call now succeeds with that termination's finish reason and no tool call. A client that sawcontent_block_start/output_item.addedfor the dropped call never receives itscontent_block_stop/output_item.done(encode.rsChange::End emitters;output.rs:1730-1742clearsopenbeforeclose). - Operators/metrics: no new config, flag, env var, default or request field; no protobuf/contract change (
runtime_core/protobuf.rsis a one-line test call-site). But the mix ofserver_errorvsstop/length/tool_callsshifts for truncated calls, and dashboard error rates drop for a class of requests. Related to #679, which #685 neither fixes nor worsens. - Dependencies: no
deepseek-recipebump; relies on its existing per-fragment action stream. - Compatibility: internal signatures only; no exported core or recipe needs re-export.
flare/flare-cliunbuilt by the author. - Docs:
docs/api.mdtool-call section rewritten (+25/−12); nothing else underdocs/and nohelios/model-contract.md(not opened) change.
Process
- Ready for review (not a draft); branch
fix/dsml-tool-call-streaming; opened and last updated 2026-12-02 18:07 — hours old at the time of this case file. - No CI checks at all on head
2f0ed9d; the only test evidence is the author's local run. - No reviews, no comments, no labels, no flare-autobot case file or review.
- Branch point 1fbcc3c predates #670 and #660 on main; a rebase is needed, and
docs/api.mdis the most frequently edited doc in the repo (every recent helios PR touches it), so that resolution deserves attention. - Reviewable size: one file at +315/−18 plus +266 of tests.
Open questions / could not find
- Is dropping the partial call (instead of erroring) a deliberate product decision or a side effect of making streamed fragments consistent? No issue, comment or review records the intent, and the inverted test name suggests the earlier "cannot retract" rule was considered.
- Did anyone want DSML streaming? No demand trail exists; #347's body could not be read (tool refused), so it may list the symptom.
- Does any consumer depend on
server_errorfor a truncated tool call (monitoring alerts, client retry logic)? Not documented anywhere found. - Do the wiped
content_block_start/output_item.addedblocks withoutcontent_block_stop/output_item.doneviolate the documented Messages/Responses event grammar?docs/api.mdnow says the call "cannot complete", but the streaming grammar isn't spelled out for that case. - Whether the self-reported flaky engram failures are truly pre-existing on main — no CI run corroborates, and the count changed between the two copies of the description.
- Whether
flare/flare-clistill build against the changed crate-internal signatures — the author did not build them; analysis says they don't reference the changed symbols, but that is inference, not a build.