Recommendation: Changes Requested
The core streaming mechanism in DsmlOutput (Call::publish with published_argument_bytes and literal deferral for string="false" values) is small, clean, and directly addresses the stalled-stream UX for multi-kilobyte DeepSeek tool calls while keeping strict-tool parking intact. However, this PR cannot merge as-is: it breaks four existing integration tests in helios/tests/ that were skipped because only --lib was run, leaves already-announced Messages/Responses tool blocks permanently unclosed (content_block_stop / response.output_item.done never emitted) when a call is truncated, and reverses reviewed pre-publication and retraction invariants without maintainer sign-off or explicit before/after disclosure in the PR description.
Merge Risk
Level: High
- Guaranteed CI breakage in
helios/tests/: Four existing integration tests inhelios/tests/deepseek_output.rsandhelios/tests/deepseek_requests.rsassert pre-streaming DSML behavior and will fail under.github/workflows/native-serving.yml:63 (not opened),68(cargo test ... --features runtime-core,serverwithout--lib). - Protocol-framing violation on streaming truncation: In
helios/src/server/output.rs:1730-1742, popping an unfinishedBlock::Toolbeforeclose()causes Messages and Responses streams to emitmessage_delta/message_stoporresponse.incomplete/response.completedwhile a previously sentcontent_block_startorresponse.output_item.addedremains open. - No runtime concurrency, memory, or TTFT regressions: All modified state (
DsmlOutput,Accumulator,ResponseOutput,Encoder) is strictly per-request (helios/src/server/http.rs:451-600);Call::publishslices into the existing 1 MiB-bounded argument buffer (O(n) total allocation), andhelios/src/server/latency.rs:116-142(stream_text) excludes tool-call deltas so TTFT metrics are unaffected.
Walkthrough
- Incremental DSML publication (
helios/src/output/dsml.rs:38, 49-62, 145-156, 191-206): MovesEvent::ToolBeginfromToolCallArgumentsEndtoToolNameEnd, addsCall::published_argument_bytesandCall::publishto emitEvent::ToolArgumentsfragments on eachToolCallArgumentsTextaction (while deferringstring="false"values untilclose_literalsettles them), and emits trailing bytes +Event::ToolEndaftervalidate_arguments. - Unfinished-call omission on non-EOS termination (
helios/src/server/output.rs:163-173, 478-480, 1730-1742,helios/src/server/protocol/encode.rs:674-677): Addsdrops_unfinished_call(cause) -> cause != Termination::Eosand threadscauseintoAccumulator::finish(cause)andResponseOutput::finish(cause)to pop an open trailing tool call instead of returningErr("incomplete emitted tool call"). - Mechanical test call-site updates (8 files): Updates
output.finish()→output.finish(Termination::Eos)acrossargument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs,pipeline.rs,xtml.rs,runtime_core/protobuf.rs, andserver/runtime/phase_tests.rs, and invertsuser_stop_cannot_retract_an_already_emitted_partial_tool_callinhelios/src/server/output.rs:1265-1274. - New unit tests & API docs (
helios/src/output/dsml.rs:749-1033,helios/src/server/protocol/tests.rs:3809-4073,docs/api.md:540-575): Adds unit tests for DSML fragment prefix/concatenation,string="false"literal deferral, truncation, and Chat end-to-end streaming, and updatesdocs/api.mdto document DSML streaming, non-EOS omission, and post-publication 1 MiB enforcement.
Pre-merge Checks
- [PASS] Security / malicious screen: No unsafe code, external I/O, or instruction-hijacking patterns; parser (1 MiB) and response (8 MiB) bounds remain enforced.
- [WARN] Charter & value fit: Streaming DSML arguments directly serves the charter's coding-agent/heavy-tool-use vision with no per-model shared-layer branch, but no issue/maintainer request exists and the PR reverses reviewed invariants (
#364pre-publication bound anduser_stop_cannot_retract_an_already_emitted_partial_tool_call) without maintainer sign-off (AGENTS.md:182-187, 204-207). - [WARN] Related / duplicate / conflict check: No duplicate PR and no textual merge conflict with
#670(itsdocs/api.mdedits start at line 586 and itsdsml.rsedits are ingrammar_envelope), but#670addedTAGGED_JSONafter the branch point, makingdocs/api.md:543-547's characterization of all tagged parsers as parameter-syntax-based stale after rebase;#364's pre-publication 1 MiB bound is directly reversed. - [WARN] Tests & verification evidence: No CI run on
2f0ed9d; author ran onlycargo test ... --lib(skippinghelios/tests/, where four existing integration tests fail) and did not build/testflareorflare-cli(docs/design-review.md:180-185).
Blockers
-
Four existing integration tests in
helios/tests/fail on head2f0ed9dhelios/tests/deepseek_output.rs:476-512(empty_and_duplicate_top_level_parameter_names_are_rejected),helios/tests/deepseek_output.rs:568-593, 596-619, 622-635(parse_literal_parameters, called bytool_call_size_includes_retained_strings_and_closing_brace_in_either_orderandliteral_nesting_includes_the_enclosing_argument_object), andhelios/tests/deepseek_requests.rs:652-687(added_non_special_dsml_token_produces_tool_calls).- Verified behavior/impact: Because the PR only ran
cargo test ... --lib, all integration tests inhelios/tests/were skipped, whereas CI (.github/workflows/native-serving.yml:63 (not opened),68) runscargo test --locked --release --manifest-path helios/Cargo.toml (not opened) --features runtime-core,server:deepseek_output.rs:511assertsassert!(published.is_empty())when feeding char-by-char input with empty or duplicate parameter names;DsmlOutput::apply(dsml.rs:145-156) now emitsEvent::ToolBeginatToolNameEndbefore parameters are parsed, sopublishedis non-empty and the assertion panics.deepseek_output.rs:576assertsassert!(output.push(Input::Text(&header))?.is_empty())on"{open}<|DSML|{s}invoke name=\"lookup\">", which now emitsEvent::ToolBeginand panics immediately (and:581asserts.is_empty()across multi-parameterstring="false"pushes even though the next parameter'sArgumentSeparatorcloses the previous literal and publishes on the next parameter key, breaking bothtool_call_size_includes_retained_strings_and_closing_brace_in_either_orderandliteral_nesting_includes_the_enclosing_argument_object).deepseek_requests.rs:683-684feeds"Berlin"one byte-token at a time via the zero-merge byte-level BPE fixture (:37-53) and evaluatesserde_json::from_str::<Value>(text).unwrap()on each individualEvent::ToolArgumentsevent; the first fragment is"{\"location\": \"B", so.unwrap()panics.
- Fix: Run the full
heliosrelease test suite (without--lib), plusflareandflare-cliperdocs/design-review.md:180-185. Updatedeepseek_requests.rs:683-684to concatenateEvent::ToolArgumentsfragments (matching lines 875-882 in the same file), and updatedeepseek_output.rs:511, 568-593once maintainers sign off on the relaxed pre-publication contract (see Should Fix #1).
-
Truncating an announced tool call leaves Messages and Responses SSE streams with unclosed blocks/items
helios/src/server/output.rs:1720-1742,helios/src/server/protocol/encode.rs:409-415, 424-429, 430-434, 470-517, 677-684, 730-745,helios/src/server/http.rs:526-573.- Verified behavior/impact: When
Event::ToolBeginarrives,Encoder::changeimmediately yieldscontent_block_start(Messages,encode.rs:411-414) orresponse.output_item.added(Responses,encode.rs:431-434) over SSE (http.rs:571-573), followed byinput_json_delta/response.function_call_arguments.deltaframes. WhenOutputLimit,UserStop,Cancelled, orExecutionErrorthen triggersEncoder::finish,ResponseOutput::finish(cause)(output.rs:1730-1742) popsself.blocksandself.callsand setsself.open = Nonebefore callingself.close(&mut changes)?, returning an emptyVec<Change>.Encoder::finishtherefore emitsmessage_delta+message_stop(Messages) withoutcontent_block_stop, andresponse.incomplete/response.completed(Responses) with"output": []withoutresponse.output_item.done(affecting both function tools and custom tools atencode.rs:366-386). Onmain, this path returnedErr("incomplete emitted tool call")and emitted a terminal error frame (error/response.failed); converting it to a "successful" terminal stream without closing the opened block violates both SSE grammars. The new truncation tests (helios/src/server/protocol/tests.rs:3809-3891, 3964-4001) only assert!finished.is_empty()andencoder.response(), so they do not detect the missing close frames. - Fix: Emit the terminal per-block close frame before omitting the unfinished tool block from the final buffered body (e.g., an explicit
Change::Abort(i)or closing before popping): emitcontent_block_stop { index: i }for Messages, andresponse.output_item.donewithstatus: "incomplete"for Responses (bypassing the custom-tool JSON/grammar validation atencode.rs:475-485for aborted calls so truncated custom-tool JSON does not turn an omission into a parse error). Add stream-framing assertions toprotocol/tests.rs:3809-4001(followingmessages_stream_reconstructs_ordered_buffered_blocksat:1098-1152and:1195-1200) verifying everycontent_block_starthas a matchingcontent_block_stopand everyresponse.output_item.addedhas a matchingresponse.output_item.done.
Should Fix
- Obtain explicit maintainer sign-off and document the contract reversals in the PR description (
AGENTS.md:88-93, 182-187, 204-207)helios/src/server/output.rs:163-173, 1265-1274,helios/src/output/dsml.rs:191-205,docs/api.md:540-555, 570-572.- Streaming DSML calls before
</|DSML|invoke>inherently reverses three previously tested guarantees:#364(authored by@voipmonitor, reviewed by@yatesdr): the 1 MiB call-size check previously ran before emitting any tool event (docs/api.md:560onmain,helios/tests/deepseek_output.rs:596-619), whereas now earlier fragments are published before the oversized append fails (docs/api.md:570-572).validate_arguments(dsml.rs:202, 398-426) runs atToolCallArgumentsEnd, so duplicate or empty parameter names now streamToolBeginand partialToolArgumentsbefore returning a delivery error (http.rs:575-579), breakingdeepseek_output.rs:511.- Truncating an already-announced call (
OutputLimit,UserStop,Cancelled,ExecutionError) previously returnedErr("incomplete emitted tool call")(server_error) as asserted byuser_stop_cannot_retract_an_already_emitted_partial_tool_call(server/output.rs:1257-1271onmain), whereas nowAccumulator::finish/ResponseOutput::finishsucceed with a cause-derivedfinish_reason("length","stop", or"tool_calls"when an earlier call completed,encode.rs:690-696) while dropping the partial call fromencoder.response()— meaning streaming Chat clients receive atool_calls[0]header/fragment delta that the final bufferedmessageomits.
- Fix: Request explicit sign-off from
@voipmonitorand@yatesdron (a) relaxing#364's pre-publication 1 MiB and key-validation guarantees for streamed DSML calls, and (b) whether truncated streamed calls should omit-and-succeed vs error (and how Chat/Messages/Responses streaming vs buffered parity is defined). Update the PR description to state these before/after behavioral reversals explicitly, and rebase ontomainsodocs/api.md:543-547accurately reflects#670'sTAGGED_JSONparser (which buffers JSON objects rather than parameter syntax).
Subtract / Simplify
- Avoid the 8-file mechanical
finish(Termination::Eos)sweep (AGENTS.md:188-193)helios/src/server/output.rs:163-173, 1730-1742,helios/src/server/protocol/encode.rs:674-677, plus 21 one-token test edits acrossargument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs,pipeline.rs,xtml.rs,runtime_core/protobuf.rs, andserver/runtime/phase_tests.rs.Encoder::finish(encode.rs:675, 677) is the sole production caller that ownscause. KeepingAccumulator::finish(&self)andResponseOutput::finish(&mut self)parameter-free and adding an explicitdrop_unfinished_call/abort_unfinished_callmethod called fromEncoder::finish(and test helperPresentation::finish) whencause.omits_unfinished_call()reverts all 8 unrelated files to zero diff and keepsfinish()a pure invariant check.
- Unify
drops_unfinished_callwithTaggedTools::eos_decisionhelios/src/server/output.rs:478-480vshelios/src/output/tagged.rs:247-255andhelios/src/output.rs:51-58.Terminationhas exactly five variants (Eos,OutputLimit,UserStop,Cancelled,ExecutionError), socause != Termination::Eos(server/output.rs:479) andmatches!(cause, Cancelled | ExecutionError | UserStop | OutputLimit)(tagged.rs:248-254) express the exact same policy in two modules with opposite polarities. Move the method ontoTerminationinhelios/src/output.rs:58(e.g.,pub(crate) fn omits_unfinished_call(self) -> bool { self != Self::Eos }), use it in bothtagged.rs:248andserver/output.rs, and deleteserver/output.rs:476-480(which is currently unnecessarilypub(crate)for same-file callers).
- Delete the redundant
call.check_size()?athelios/src/output/dsml.rs:191helios/src/output/dsml.rs:191-192vshelios/src/output/dsml.rs:218-220.apply()writes into a localeventsVec owned bypush()(:359) orfinish()(:387) that is discarded wheneverapply()returnsErr.call.publish(:192) does not mutatecall.nameorcall.arguments, so:218-220checks identical state and discardseventson overflow identically. Delete:191(keep:201inToolCallArgumentsEnd, whereself.call.take()at:196bypasses:218).
- Deduplicate
docs/api.mdfinish-reason textdocs/api.md:547-551duplicates the normative finish-reason mapping already defined atdocs/api.md:580-589, and line 550-551 ("A client that received fragments of such a call has already seen a call that cannot complete") omits the concrete wire framing behavior clients must handle. Keep only the omission rule at:547-549, cross-reference:580-589for finish reasons, and state the exact terminal SSE event behavior once Blocker #2 is fixed.
Nits
- Disambiguate duplicate test function names:
a_truncated_second_call_keeps_the_completed_first_callanda_header_only_call_is_omitted_when_the_response_truncatesappear verbatim in bothhelios/src/output/dsml.rs:940-984(testingDsmlOutput+Accumulator) andhelios/src/server/protocol/tests.rs:3894-4001(testing syntheticEvents intoEncoder), makingcargo test <name>run both layers ambiguously. Rename one pair with a layer prefix (e.g.,dsml_...vsencoder_...) and add aProtocol::Messages/Protocol::Responsesend-to-endOutputPipeline→Encodertest alongsidedsml_arguments_reach_the_chat_wire_while_the_call_is_open(protocol/tests.rs:4004-4073). - PR description detail on
string="false": Note briefly thatstring="false"parameters do not stream incrementally (the entire parameter value is held untilclose_literalruns), so onlystring="true"parameters stream mid-value.
Dropped on verification
- Claim that
drops_unfinished_callchanges truncation fromserver_errorto success for all tool dialects (upstream F2 / Value Proposition): Dropped as overstated. Verified acrosshelios/src/output/tagged.rs:262-278,recipient.rs:182-193, 275-286,tml.rs:357-368, andxtml.rs:205-216that every non-DSML production parser emits[ToolBegin, ToolArguments, ToolEnd]atomically and already omits truncated envelopes inside the parser's ownfinish(cause). Only DSML (and synthetic test parsers likeControls) can leave an open call inAccumulator/ResponseOutput. Retained the verified DSML/contract-reversal scope under Should Fix #1. - Claim of a non-trivial merge conflict with
#670indocs/api.md(upstream Dossier / F3 open question #7): Dropped as false. Verified againstmain(docs/api.md:525-625,helios/src/output/dsml.rs:1-410):#670editeddocs/api.md:586-625andDsmlOutput::grammar_envelope, while PR #685 editsdocs/api.md:537-577andDsmlOutput::apply, so there is no textual conflict (only a semantic doc update needed to account forTAGGED_JSON). - Claim of per-fragment SSE "frame amplification" overhead on the common path (upstream F7): Dropped as low-signal. Emitting one SSE frame per decoded token matches existing
Event::ContentandEvent::Reasoningstreaming (encode.rs:626-653); it is the intended behavior of token-level streaming rather than an anomalous amplification. - Proposed fixes that contradict streaming or the OpenAI spec (upstream F3/F4 "validate before publishing" and F5 "emit an aborted-call delta on Chat"): Dropped as invalid. Validating the complete argument object or final 1 MiB total before publishing would revert streaming altogether, and OpenAI Chat Completions has no standard "aborted tool call" delta field.
- Claim that
protocol/tests.rs:3894-4001strictly subsumesdsml.rs:940-984(upstream S3): Refined/dropped the "strictly subsumes" claim —protocol/tests.rs:3894-4001injects syntheticEvents intoEncoderand does not exerciseDsmlOutput, so the issue is only ambiguous duplicate test names (moved to Nits). - Speculation about PR body test-count drift between snapshots (upstream F8): Dropped as unverified/low-signal in favor of the concrete, verified test gap (running
--libskipped four failing tests inhelios/tests/).