Opened by a workflow run, Dec 2, 2026 1:07 PM EST. decide malicious: all_clear (100%): No malicious content found
explore
Author: peperunas (FIRST_TIME_CONTRIBUTOR; one previous PR #519, closed unmerged; Discord: peperunas)
Motivation: Flare's DeepSeek (DSML) parser collected a tool call's whole argument object and only released it to the client when the closing tag arrived, so a multi-kilobyte write argument left the SSE stream silent for the entire generation — indistinguishable from a hung model. The pull request publishes the call name as soon as the header completes and streams argument fragments as the model writes them.
Scale: +662 / −72 lines in 13 files
Proposal:
DsmlOutput::applyemitsEvent::ToolBeginatToolNameEndinstead of atToolCallArgumentsEnd(helios/src/output/dsml.rs:145-156).- A new
Call::publish()cursor emitsEvent::ToolArgumentsfor each appended fragment, withholdingstring="false"values whileclose_literalmay still rewrite them (dsml.rs:38,49-62,173-206). Accumulator::finish(cause)/ResponseOutput::finish(cause)now drop an announced-but-unfinished call for every cause exceptEosvia a newdrops_unfinished_callpredicate (helios/src/server/output.rs:163-173,478-480,1730-1742);Encoder::finishthreads the cause through (encode.rs:658-677).- The pre-existing test
user_stop_cannot_retract_an_already_emitted_partial_tool_callis inverted touser_stop_omits_an_already_emitted_partial_tool_call(output.rs:1265-1274). docs/api.md:540-572now documents per-parser streaming, what fragments concatenate to, and truncation behaviour — replacing main's "parsers buffer tool envelopes until they are complete" (docs/api.md:540-541on main). Touches:helios/src/server/output.rs(truncation/omission semantics for every parser and protocol)helios/src/output/dsml.rs(DSML parser event timing)helios/src/server/protocol/encode.rs+docs/api.md(cause plumbing, wire documentation) Related items:- #364 Retain/enforce DeepSeek tool-call size before emitting any tool event (merged): #685 reverses its publish-after-check property
- #359 Retain DeepSeek tool values that are not valid JSON (merged): source of the
literalmachinerypublish()must defer to - #418 Strict function-tool schemas for DSML/Qwen/GLM/TML (merged): its strict parking path is preserved
- #333 Complete responses after one tool call when parallel calls are disabled (merged): its
Cancelledpath is reused as a drop cause - #670 THINK_TAGS/TAGGED_JSON + eight of the same files (merged): landed after #685 branched; rebase needed in api.md and two test files
Link: https://github.com/NVIDIA/hyperflare-inference/pull/685
Autobot comments: The description presents this as a streaming fix, but it also contains a universal, wire-visible behaviour change: a tool call cut off by UserStop, Cancelled or ExecutionError is now omitted from the buffered body with that termination's finish reason, where main returned the
server_error"incomplete emitted tool call" — and a test that asserted the old contract ("cannot retract") was inverted without being called out. It applies to all seven-plus parsers and all three protocols while the streaming win is DSML-only. It also reverses #364's deliberate "check size before emitting any tool event" property (documented instead of hidden) and deletes the docs sentence that documented buffering as intended. No issue asks for this and no maintainer requested it; evidence is the author's own live run (566 frames / 2196 bytes hashed equal to non-streaming) with no CI checks, no reviews and zero comments.
Value Proposition
Value Proposition — PR #685 "fix(frontend): stream DeepSeek tool-call arguments"
Charter alignment — mostly yes. The vision targets "coding agents, and heavy tool use"; a DSML call that leaves function.arguments silent for a multi-kilobyte write value is exactly that workload's failure mode, and the fix changes when the parser publishes rather than swallowing an error (#397). No shared-layer per-model branch is added: DsmlOutput is the only parser changed semantically, and drops_unfinished_call is a Termination predicate, not a dialect flag (#267, #334). The description carries the four expected parts and is candid that the tagged dialects still buffer, were not exercised live, and that flare/flare-cli were not built.
Novelty — genuinely additive. Nothing on main streams DSML argument fragments; open #577 and #575 touch other dialects. Not obsolete, not superseded by any open PR.
Fit risk — no demand trail. "What gets merged" wants a maintainer request, roadmap item, reproducible bug, or measured issue. No issue asks for streaming tool arguments; docs/api.md:540-541 on main documented the buffering as the contract. Evidence is served-workload measurement (566 frames / 2196 bytes, hash-equal to non-streaming), but self-reported, single model, author's own endpoint, with no CI on head 2f0ed9d and test counts that shifted in the body (1783/18 → 1787/16) while the commit stayed the same.
Cost — a second, undisclosed behaviour change rides along. Behind the DSML-only win, Accumulator::finish(cause)/ResponseOutput::finish(cause) drop announced-but-unfinished calls for every termination except Eos — all tool parsers, all three wire protocols — turning main's server_error "incomplete emitted tool call" into success. That inverts the deliberate user_stop_cannot_retract_an_already_emitted_partial_tool_call test (renamed, one clause of the body) and reverses #364's reviewed "check the 1 MiB bound before emitting any tool event" ordering, now documented as tripping after publication. Clients that received content_block_start/output_item.added for a dropped call never get its closing event. #670 rewrote the same docs/api.md parser section after the branch point, so a rebase is required.
Verdict: Worth it with changes. The streaming fix is root-cause, small-footprint, and serves the target workload. It should not carry a universal, unstated truncation-semantics reversal: split that into its own PR with a filed rationale, or drop it and keep main's error. Re-negotiate the #364 bound with @voipmonitor and @yatesdr, rebase over #670, get CI green, and state the truncation change in the body as the reversal it is.
Full report Decide Value: yes (99%): This change is worth reviewing: it provides value to the project in line with its charter.
Classify intake
Selected: triage:review, performance, area:api, model:deepseek-v4, model:deepseek-v4.1
Threshold: 65%
Triage
- [✓]
triage:review: 95.6% -
triage:design-review: 4.2% -
triage:validation: 0.1% -
triage:integration: 0.0% -
triage:partial: 0.0% -
triage:investigate: 0.0% -
none: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Priority
-
none: 98.2% -
priority:P2: 1.4% -
priority:P1: 0.4%
Type
- [✓]
performance: 65.1% -
bug: 59.3% -
enhancement: 53.1% -
community: 32.1% -
duplicate: 2.9% -
documentation: 0.1%
Area
- [✓]
area:api: 94.7% -
area:engram: 20.2% -
area:preparation: 2.3% -
area:selene: 2.3% -
area:orbit: 1.8% -
area:memory: 1.4% -
area:rocenante: 0.8% -
area:caching: 0.6% -
area:scheduling: 0.1% -
area:kernels: 0.0% -
area:packaging: 0.0%
Model
- [✓]
model:deepseek-v4.1: 85.2% - [✓]
model:deepseek-v4: 70.6% -
model:glm-5.3: 1.8% -
model:qwen3.8-flash-next: 1.8% -
model:qwen3.8-27b: 1.0% -
model:muse-glimmer: 0.9% -
model:inkling-small: 0.4% -
model:kimi-k3.1: 0.3% -
model:nemotron-3.5-bolt: 0.3% -
model:mimo-v2.6: 0.2% -
model:gemma4: 0.2%
Apply Labels (Intake)
Applied: +triage:review, +performance, +area:api, +model:deepseek-v4, +model:deepseek-v4.1
Subtraction and simplicity
Subtraction/Simplicity review of PR #685 (fix(frontend): stream DeepSeek tool-call arguments). The production change itself is lean — DsmlOutput::publish is six lines, the Event::ToolBegin move is a net deletion, and no new flag, knob, env var, trait, enum variant or per-model branch is added — but four subtraction items and one dead line are worth fixing.
- One rule spelled twice (high): the new
drops_unfinished_call(cause) { cause != Termination::Eos }(helios/src/server/output.rs:476-480) is logically identical to the existing four-armmatches!inTaggedTools::eos_decision(helios/src/output/tagged.rs:247-255), sinceTerminationhas exactly those five variants (helios/src/output.rs:51-58). Move the predicate beside the enum and use it there; the copy'spub(crate)is also unnecessary since both uses are in the same module. finish(cause)sweep (high): the new mandatorycauseargument onAccumulator::finish(output.rs:163) andResponseOutput::finish(output.rs:1730) has exactly one production caller (helios/src/server/protocol/encode.rs:675,677); every other call site is a test passingTermination::Eos, and eight of thirteen changed files exist only for that sweep (argument_tags.rs,chatml.rs,gemma_call.rs(not opened),minimax_xml.rs,pipeline.rs,xtml.rs,runtime_core/protobuf.rs,server/runtime/phase_tests.rs). An explicitdrop_unfinished_call(&mut self)called fromEncoder::finishremoves the threading and the churn; counterweight:ModelOutput::finish(cause)already exists in the same layer (helios/src/output.rs:92,97).- Same-named duplicate tests (medium):
a_truncated_second_call_keeps_the_completed_first_callanda_header_only_call_is_omitted_when_the_response_truncateseach exist twice, inhelios/src/output/dsml.rs:940,963andhelios/src/server/protocol/tests.rs:3894,3964; the parser copies (~46 lines) are subsumed by the wire copies. docs/api.md:547-551restates the finish-reason mapping already specified atdocs/api.md:580-589, anddocs/api.md:550-551argues for the design instead of specifying behaviour (AGENTS.md:52-60).call.check_size()?atdsml.rs:191duplicates the loop-tail check atdsml.rs:218-220with no mutation between them; delete line 191 (the one atdsml.rs:201must stay, that arm takes the call).
Open: whether the finish(cause) shape is deliberate consistency with the parser trait; whether the truncation semantics change (documented at docs/api.md:570-572 for the 1 MiB bound, and the dropped-call rule) needs a maintainer decision (#364, #333); and whether the flaky-engram test claim holds, which no CI run corroborates.
Correctness and contracts
PR #685 (stream DeepSeek tool-call arguments) has a sound core mechanism but four serious problems elsewhere in the diff.
Blockers/major
- F1 Blocker — announced calls never get their terminal stream frame.
ResponseOutput::finish(output.rs:1730-1742) pops the tool block and clearsopenbeforeclose()(output.rs:1720-1729), the only producer ofChange::End, which is the sole trigger forcontent_block_stop(encode.rs:424-429) andresponse.output_item.done(encode.rs:513-516) — whileChange::Startalready sent the opening frames (encode.rs:409-434). Every truncated Messages/Responses stream leaves a permanently open content block.mainat least failed the request. - F2 Major — universal truncation reversal.
drops_unfinished_call(cause) = cause != Eos(output.rs:476-480) turns aserver_errorinto success for every dialect and all three protocols, though only DSML streams; it inverts the deliberately nameduser_stop_cannot_retract_an_already_emitted_partial_tool_calltest (diff hunk atoutput.rs:~1262) with no maintainer sign-off. - F3 Major — two documented invariants reversed silently in
docs/api.md: the "parsers buffer tool envelopes" contract (docs/api.md:540-555) and #364's check-before-publish 1 MiB bound (docs/api.md:570-572vsdsml.rs:191-192). - F4 Major —
validate_argumentsruns after publishing (dsml.rs:194-206), so a rejected argument object streams invalid partial JSON and leaves the announced call open forever;mainpublished nothing on that path. - F5 Major — Chat orphan delta: the id/name delta was sent (
output.rs:111) for a call the final message drops (output.rs:163-168,:179-181). - F6 Blocker-adjacent test gap: the new truncation tests assert only
finish(...).is_ok()and the final body (protocol/tests.rs:3859-3896,:3984-3996) — exactly what stays correct while F1 is broken; the repo's frame-reconstruction idiom (protocol/tests.rs:1098-1151,:1195-1200) is not applied. - F7 Minor: ~566 SSE frames for 2196 bytes, no coalescing, unmeasured vs
main;Cancellednow reportsfinish_reason:"stop"(encode.rs:690-696), masking cancellation in metrics.
Verified clean: no lock/queue contention, no memory amplification (dsml.rs:57-60 slices), string="false" deferred correctly, strict parking untouched (encode.rs:564-621), abort path unaffected.
Open: whether dropping the partial call is deliberate; whether the missing stream close is acceptable to contract owners; why counts changed at an unchanged head (no CI at all); whether flare/flare-cli build.
Final review
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/).
Classify triage
Selected: triage:review
Threshold: 65%
Triage
- [✓]
triage:review: 94.0% -
triage:design-review: 6.0% -
triage:partial: 0.0% -
triage:validation: 0.0% -
triage:integration: 0.0% -
triage:investigate: 0.0% -
none: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Apply labels
No label changes Decision to Test: no (100%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with. decide malicious: all_clear (100%): No malicious content found
explore
Author: peperunas (FIRST_TIME_CONTRIBUTOR; prior PR #519 closed unmerged; Discord: peperunas)
Motivation: DeepSeek tool calls arrive silently: the DSML parser holds the whole call until the closing tag, so a multi-kilobyte write argument leaves the client stream blank for the entire generation, which looks like a hang. The PR publishes the call name as soon as the header completes and streams argument fragments as the model writes them.
Scale: +662 / −72 lines in 13 files
Proposal:
- Move
Event::ToolBeginfromToolCallArgumentsEndtoToolNameEndand addCall::published_argument_bytes/Call::publishso each argument-text action emits a fragment (dsml.rs:38,49-62,145-206). - Withhold
string="false"values whileclose_literalmay still rewrite them, so no published byte changes. - Add
drops_unfinished_call(cause) -> cause != Termination::Eosand threadcauseintoAccumulator::finish/ResponseOutput::finish, popping an announced-but-unfinished call instead of returningErr("incomplete emitted tool call")(output.rs:163-173,478-480,1730-1742). - Invert
user_stop_cannot_retract_an_already_emitted_partial_tool_callintouser_stop_omits_…(output.rs:1265-1274) and rewrite thedocs/api.md:540-572parser section. - Mechanical
finish()→finish(Termination::X)call-site updates in eight files. Touches: helios/src/server/output.rs— universal non-EOS truncation semantics, all parsers and all three protocolshelios/src/output/dsml.rs— the streaming rewrite and its size-bound/validation orderingdocs/api.md+helios/src/server/protocol/tests.rs— contract rewrite and new coverage Related items:- #364 (merged): its reviewed "1 MiB check before any tool event" bound is reversed — now enforced after publication (
docs/api.md:570-572) - #670 (merged): TAGGED_JSON landed after the branch point, making the PR's tagged-parser doc sentence false; rebase is semantic
- #359 (merged): source of the literal/
close_literalmachinerypublishdefers to - #418 (merged): strict-tool parking preserved; its "zero leaked partial calls" evidence is the guarantee this PR reinterprets
- #573 / #577 (open): neighbouring output-layer PRs that drew automated review immediately, unlike this one
Link: https://github.com/NVIDIA/hyperflare-inference/pull/685
Autobot comments: Four existing integration tests break (
deepseek_output.rs:576,581,511,deepseek_requests.rs:683-684) and CI runs them without--lib(native-serving.yml:63,68); the author's--lib-only evidence cannot see this. Truncation also drops the tool block beforeclose(), leavingcontent_block_start/response.output_item.addedunclosed while terminal frames still emit (encode.rs:409-415,424-428,730-745).
Classify intake
Selected: triage:review, bug, performance, enhancement, area:api, model:deepseek-v4, model:deepseek-v4.1
Threshold: 65%
Triage
- [✓]
triage:review: 93.9% -
triage:design-review: 6.0% -
triage:validation: 0.0% -
triage:integration: 0.0% -
none: 0.0% -
triage:investigate: 0.0% -
triage:partial: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Priority
-
none: 95.7% -
priority:P2: 2.9% -
priority:P1: 1.4%
Type
- [✓]
performance: 88.1% - [✓]
enhancement: 75.5% - [✓]
bug: 67.9% -
community: 50.0% -
duplicate: 40.7% -
documentation: 0.5%
Area
- [✓]
area:api: 99.5% -
area:selene: 7.6% -
area:memory: 3.7% -
area:engram: 2.3% -
area:orbit: 1.6% -
area:preparation: 1.6% -
area:scheduling: 0.5% -
area:rocenante: 0.4% -
area:caching: 0.3% -
area:kernels: 0.1% -
area:packaging: 0.1%
Model
- [✓]
model:deepseek-v4: 85.2% - [✓]
model:deepseek-v4.1: 81.8% -
model:gemma4: 1.6% -
model:qwen3.8-27b: 1.1% -
model:qwen3.8-flash-next: 1.1% -
model:kimi-k3.1: 1.0% -
model:mimo-v2.6: 1.0% -
model:glm-5.3: 0.8% -
model:inkling-small: 0.5% -
model:muse-glimmer: 0.3% -
model:nemotron-3.5-bolt: 0.1%
Apply Labels (Intake)
Applied: +bug, +enhancement
Subtraction and simplicity
The core streaming change in #685 is lean — Call::publish is ~10 lines, one new field, no new event variant, no flag or wrapper, and ToolCallArgumentsEnd is a net −9-line simplification of an old 3-event extend. Removability is concentrated in two high-value places.
-
The
finish(cause)parameter sweep (high).Accumulator::finishandResponseOutput::finishgained aTerminationargument (output.rs:163,:1730) whose only job is one boolean,drops_unfinished_call(cause)=cause != Eos(output.rs:476-480). It costs 21 mechanically edited call sites across 8 files that change nothing else (+21/−21:argument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs(not opened),pipeline.rs,xtml.rs,protobuf.rs,phase_tests.rs), ~8 more inoutput.rstests, and 6 indsml.rs, while the decision is made at exactly one place:encode.rs:674-677. Replace withfinish()unchanged plus onedrop_unfinished(&mut self)called fromEncoder::finishwhencause != Termination::Eos; the helper disappears entirely. -
Two duplicated tests, under identical names (high).
a_truncated_second_call_keeps_the_completed_first_callexists atdsml.rs:940andprotocol/tests.rs:3894;a_header_only_call_is_omitted_when_the_response_truncatesatdsml.rs:963andprotocol/tests.rs:3964. Keep the protocol-level copies (they assert the user-visible buffered body andfinish_reasonacross three protocols); the dsml copies repeat whatdsml.rs:793and:917already assert. Alsorejection_tests::end_of_sequence_inside_an_announced_call_is_an_error(dsml.rs:1003-1011) restates existing integration coverage. -
Duplicate size check (medium).
dsml.rs:191call.check_size()?was added immediately beforepublish, but the pre-existing post-match check atdsml.rs:218-220already runs on the same iteration over the same state. Delete line 191. -
Docs overreach (medium).
docs/api.md:544-548justifies the tagged parsers (untouched by this PR, and the justification is already false forTAGGED_JSON), and:551-552("A client that received fragments of such a call has already seen a call that cannot complete") is commentary that describes the unresolved missing-stop-frame gap.
Open: whether the automated review's "Subtract/Simplify: 4" items are these; whether the dsml-level duplicates were deliberate layering; minimax_xml.rs (not opened) and phase_tests.rs diffs were inferred mechanical (+1/−1, +2/−2) rather than read.
Correctness and contracts
PR #685 at head 80c87b3 streams DSML tool-call fragments correctly at the parser layer, but the surrounding contract work is not safe to merge: it trades a silent-generation complaint for unclosed protocol blocks, broken integration tests, and a silently weakened error guarantee.
Findings, most important first:
- Blocker — an announced-but-dropped call leaves a Messages/Responses block unclosed.
ResponseOutput::finishpops the block and clearsopenbeforeclose(), the only producer ofChange::End(helios/src/server/output.rs:1730-1742), yetEncoder::finishstill sendsmessage_delta/message_stopandresponse.incomplete/response.completed(helios/src/server/protocol/encode.rs:730-745), socontent_block_start/response.output_item.addednever get their stop/done, andstop_reasoncontradicts the stream. - Blocker — four existing integration tests fail on merge; CI runs the whole
heliostarget (.github/workflows/native-serving.yml:63 (not opened),68) and the author's--libevidence cannot see them (helios/tests/deepseek_output.rs:511,576,581,helios/tests/deepseek_requests.rs:684). - Blocker —
drops_unfinished_call(cause) -> cause != Termination::Eos(helios/src/server/output.rs:476-480) turnsErr("incomplete emitted tool call")into success for UserStop, Cancelled and ExecutionError, with finish reasonstop/end_turn, documented as contract (docs/api.md:547-551) and pinned by an inverted test (output.rs:1265-1274) — a weakened guarantee with no maintainer decision (AGENTS.md:182-187, 201-207). - Major — the 1 MiB bound is now enforced after publication (
docs/api.md:568-572,helios/src/output/dsml.rs:189-192), reversing #364's pre-publication invariant and compounding finding 1 on overflow. - Minor —
docs/api.md:543-547describes tagged parsers as schema-building, already false forTAGGED_JSON(#670).
Sound: fragment bytes concatenate exactly to stored arguments, string="false" withholding, strict parking, per-request state only, no new contention/amplification, TTFT sampling unchanged.
Re-review
Recommendation: Changes Requested
The core streaming mechanism in DsmlOutput (Call::publish with published_argument_bytes and string="false" literal deferral) is minimal, byte-exact, and directly solves stalled streaming for large DeepSeek tool calls without adding per-model runtime branches or hurting concurrency/TTFT. However, the PR at 80c87b3 breaks four existing integration tests in helios/tests/ that CI runs unconditionally, introduces a streaming SSE framing violation on Messages and Responses when an announced tool call is truncated, and reverses the reviewed Err("incomplete emitted tool call") contract on UserStop/Cancelled/ExecutionError without maintainer sign-off.
Merge Risk
Level: High
- Guaranteed Linux and Windows CI failure in
helios/tests/:.github/workflows/native-serving.yml:63 (not opened), 68run the fullheliostest target without--lib; four existing integration tests inhelios/tests/deepseek_output.rsandhelios/tests/deepseek_requests.rsassert pre-streaming DSML behavior and will fail. - SSE protocol-framing violation on streaming truncation:
ResponseOutput::finish(helios/src/server/output.rs:1730-1742) drops an openBlock::Toolbeforeclose(), so Messages and Responses streams sendmessage_stop/response.completed/response.incompletewhile a previously announcedcontent_block_startorresponse.output_item.addedremains permanently unclosed and vanishes fromresponse.output. - No runtime concurrency, memory amplification, or TTFT regressions: All modified state (
DsmlOutput,Accumulator,ResponseOutput,Encoder) is strictly per-request (helios/src/server/http.rs:451-600),Call::publishslices only newly appended bytes within the 1 MiB buffer (O(n) total allocation), strict-tool parking (helios/src/server/protocol/encode.rs:585-624) still withholds all frames until schema validation passes, andstream_text(helios/src/server/latency.rs:116-142) excludes tool-call deltas so TTFT metrics are unaffected.
Walkthrough
- Incremental DSML tool-call streaming (
helios/src/output/dsml.rs:38, 49-62, 145-156, 191-206): EmitsEvent::ToolBeginatOutputAction::ToolNameEnd, tracksCall::published_argument_bytesand publishesEvent::ToolArgumentsfragments after eachToolCallArgumentsTextappend (while withholdingstring="false"literals untilclose_literalsettles them), and flushes remaining bytes plusEvent::ToolEndaftervalidate_argumentsatToolCallArgumentsEnd. - Unfinished-call omission on non-EOS termination (
helios/src/server/output.rs:163-173, 476-480, 1730-1742,helios/src/server/protocol/encode.rs:674-677): Addsdrops_unfinished_call(cause) -> cause != Termination::Eosand threadscauseintoAccumulator::finishandResponseOutput::finishto pop an open trailing tool call instead of returningErr("incomplete emitted tool call"). - Mechanical test call-site churn and inverted retraction test (9 files): Updates
output.finish()→output.finish(Termination::Eos)acrosshelios/src/output/{argument_tags,chatml,gemma_call,minimax_xml,pipeline,xtml}.rs,helios/src/runtime_core/protobuf.rs,helios/src/server/runtime/phase_tests.rs,dsml.rs, andoutput.rs, and rewritesuser_stop_cannot_retract_an_already_emitted_partial_tool_callintouser_stop_omits_an_already_emitted_partial_tool_call(helios/src/server/output.rs:1265-1274). - New unit tests and API documentation (
helios/src/output/dsml.rs:749-1033,helios/src/server/protocol/tests.rs:3809-4073,docs/api.md:540-574): Adds DSML streaming/truncation/rejection tests and Chat/Messages/Responses buffered truncation tests plus an end-to-end DSML→Chat wire test, and updatesdocs/api.mdfor 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; 1 MiB parser (
dsml.rs:22, 42-47, 234-236) and 8 MiB response (output.rs:119-121, 1817-1819) 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 or maintainer request is linked, and the PR reverses reviewed error/pre-publication invariants (
user_stop_cannot_retract_an_already_emitted_partial_tool_calland#364) without maintainer sign-off (AGENTS.md:182-187, 201-207). - [WARN] Related / duplicate / conflict check: No duplicate PR and no textual merge conflict with
#670(itsdocs/api.mdedits begin at line 586 onmainand itsdsml.rsedits are ingrammar_envelope), but#670addedTAGGED_JSONafter the branch point, makingdocs/api.md:543-547factually false againstmain. - [WARN] Tests & verification evidence: Only
cargo test ... --libwas run (missing the 4 failing integration tests inhelios/tests/), 16 tests failed locally (6 missingFLARE_TEST_TEMPLATE_DIR, 10 parallel engram tests), andflare/flare-cliwere not built or tested (docs/design-review.md:180-185).
Blockers
-
Four existing integration tests in
helios/tests/fail under CI (.github/workflows/native-serving.yml:63 (not opened), 68):- CI runs
cargo test --locked --release --manifest-path helios/Cargo.toml (not opened) --target-dir flare-cli/target --features runtime-core,server(without--lib), and this PR modifies no files inhelios/tests/. helios/tests/deepseek_output.rs:576, 581(parse_literal_parameters, used bytool_call_size_includes_retained_strings_and_closing_brace_in_either_orderat:596-619andliteral_nesting_includes_the_enclosing_argument_objectat:622-635): assertsoutput.push(Input::Text(&header))?.is_empty()andoutput.push(Input::Text(¶meter))?.is_empty().ToolNameEndnow emitsEvent::ToolBegin(helios/src/output/dsml.rs:145-156) and parameter key text emitsEvent::ToolArguments(dsml.rs:191-192), failing both assertions.helios/tests/deepseek_output.rs:510-511(empty_and_duplicate_top_level_parameter_names_are_rejected): assertspublished.is_empty()after duplicate/empty key rejection, butEvent::ToolBeginand early argument fragments are now emitted beforevalidate_argumentsruns atToolCallArgumentsEnd(dsml.rs:151-155, 192, 202).helios/tests/deepseek_requests.rs:683-684(added_non_special_dsml_token_produces_tool_calls): runsserde_json::from_str::<Value>(text).unwrap()on a singleEvent::ToolArgumentsevent, which panics now that individual events carry partial JSON fragments.- Fix: Update these four integration tests to match incremental DSML emission (collect/verify streamed
ToolBeginand concatenatedToolArguments, verify noToolEndis emitted on rejected/oversized calls) and verify with the full CI test commands acrosshelios,flare, andflare-cli(docs/design-review.md:180-185).
- CI runs
-
Truncating an announced tool call leaves Messages and Responses SSE blocks/items permanently unclosed (
helios/src/server/output.rs:1730-1742,helios/src/server/protocol/encode.rs:409-517, 730-745):ResponseOutput::applyemitsChange::Start(i)onEvent::ToolBegin(output.rs:1792-1802), which sendscontent_block_starton Messages (encode.rs:409-415) andresponse.output_item.addedon Responses (encode.rs:430-434).- On non-EOS termination,
ResponseOutput::finish(output.rs:1730-1742) popsself.blocks, popsself.calls, and setsself.open = Nonebefore callingself.close(&mut changes)(output.rs:1720-1729), which is the sole producer ofChange::End(i)— andChange::End(i)is the sole producer ofcontent_block_stop(encode.rs:424-429) andresponse.output_item.done(encode.rs:470-517). Encoder::finish(encode.rs:730-745) then unconditionally sendsmessage_delta/message_stop(withstop_reason: "end_turn"/"max_tokens"/"stop_sequence") orresponse.incomplete/response.completed(whoseresponse.outputomits the announced item) without ever closing the open tool block/item. This breaks strict SSE parsers/SDK assemblers for both function tools and Responses custom tools (encode.rs:458-460).- The new tests in
helios/src/server/protocol/tests.rs:3810-4001miss this because they assert onlyencoder.response()and!finished.is_empty(), never the emitted frame sequence. - Fix: Do not emit terminal
message_stop/response.completed/response.incompleteframes while a previously announced block/item is unclosed. Either preserveErr("incomplete emitted tool call")(sohttp.rs:575-579terminates the stream withencoder.failure(&e)), or — for causes where omission from the final body is approved (e.g.,OutputLimit) — emit a valid closing frame (content_block_stopon Messages; on Responses,response.output_item.donewithstatus: "incomplete", skipping the complete-JSON custom-tool validation atencode.rs:475-485) before omitting the incomplete item from the final response. Add frame-sequence assertions tohelios/src/server/protocol/tests.rs:3810-4001.
-
Unapproved reversal of
Err("incomplete emitted tool call")forUserStop,Cancelled, andExecutionError(helios/src/server/output.rs:163-173, 476-480, 1265-1274, 1730-1742,docs/api.md:547-551):drops_unfinished_call(cause)(output.rs:478-480) returnstruefor everyTerminationexceptEos, silently omitting an already-announced incomplete tool call across all parsers and all three wire protocols instead of returningErr("incomplete emitted tool call").- While production HTTP execution errors still travel via
GenerationEvent::Error(e)→encoder.failure(&e)(helios/src/server/http.rs:562-579,helios/src/server/runtime.rs:321-329, 2053-2070, 2351-2373),UserStop(matched stop string mid-call) andCancelleddo flow throughEncoder::finish— and direct callers ofAccumulator/ResponseOutput/Encoder::finishwithExecutionErroralso now succeed withfinish_reason: "stop"/end_turn/completedand notool_callsafter already streaming partial tool frames. - The PR renames and inverts the regression test that pinned this invariant (
user_stop_cannot_retract_an_already_emitted_partial_tool_call→user_stop_omits_an_already_emitted_partial_tool_call,output.rs:1265-1274) and rewritesdocs/api.md:547-551without an explicit maintainer design decision, contraveningAGENTS.md:182-187, 201-207("Do not ... suppress errors ... Apply these criteria to documentation and test changes that would weaken the rules as well as code"). - Fix: Narrow unfinished-call omission to
Termination::OutputLimit(consistent withmain'sdocs/api.md:542-543contract for output-limit truncation) and keepErr("incomplete emitted tool call")plususer_stop_cannot_retract_an_already_emitted_partial_tool_callforUserStop/Cancelled/ExecutionError, or obtain explicit maintainer sign-off before changing that contract.
Should Fix
-
docs/api.md:543-547is already factually inaccurate againstmain(#670TAGGED_JSON):docs/api.md:543-547claims that "The tagged tool parsers publish a call only when its envelope is complete, because they build its arguments from parameter syntax and the declared schemas rather than copying the model's text: values are coerced to declared types, strict container parameters are parsed, and wrapping newlines are trimmed."- On
main,#670addedTAGGED_JSON(helios/src/output/tagged_json.rs:12-66onmain,docs/api.md:610-619onmain), which setsTRIM_NEWLINES = falseandJSON_BODY = true, parses the model's{"name": ..., "arguments": ...}JSON object directly without parameter syntax or schema coercion, and re-serializesobject["arguments"].to_string(). - Additionally,
docs/api.md:550-551("A client that received fragments of such a call has already seen a call that cannot complete.") is commentary rather than wire specification. - Fix: Rebase onto
main, replace lines543-547with a concise, dialect-accurate sentence (e.g., "The other tool parsers publish a call only when its envelope is complete, so their argument events do not imply incremental generation."), and replace lines550-551with the concrete wire-framing contract resolved in Blocker #2.
-
Disclose and obtain maintainer sign-off on relaxing
#364's pre-publication 1 MiB bound (docs/api.md:569-572,helios/src/output/dsml.rs:145-156, 189-192):#364intentionally enforced the 1 MiB combined name+arguments limit before emitting the first tool event (docs/api.md:560onmain: "Helios rejects a larger call before publishing it.").- Incremental streaming inherently relaxes this:
Event::ToolBeginand earlierEvent::ToolArgumentsfragments are emitted before a later append crosses 1 MiB (dsml.rs:191still rejects the crossing fragment beforepublishat:192, andhttp.rs:575-579terminates the stream with an error frame). - Fix: Call out this
#364contract relaxation explicitly in the PR description and get maintainer sign-off (@voipmonitor/@yatesdr) perAGENTS.md:201-207.
Subtract / Simplify
-
Eliminate
finish(cause)churn across 8 unrelated files (helios/src/server/output.rs:163-173, 476-480, 1730-1742,helios/src/server/protocol/encode.rs:674-677):- Adding
cause: TerminationtoAccumulator::finishandResponseOutput::finishproduces mechanical+21/-21edits across 8 otherwise-untouched files (helios/src/output/{argument_tags,chatml,gemma_call,minimax_xml,pipeline,xtml}.rs,helios/src/runtime_core/protobuf.rs,helios/src/server/runtime/phase_tests.rs) plus 15 test call sites indsml.rsandoutput.rs, for a single production caller (encode.rs:674-677). - Simplification: Keep
Accumulator::finish(&mut self)andResponseOutput::finish(&mut self)zero-argument, deletedrops_unfinished_call, and invoke an explicit truncation method (e.g.drop_unfinished/finish_truncated) only fromencode.rs:674-677for the approved truncation cause(s). This removes 8 files from the PR diff.
- Adding
-
Deduplicate new unit test structure in
helios/src/output/dsml.rs:940-1032:rejection_tests(dsml.rs:988-1032) duplicatesstreaming_tests's fixture/imports (dsml.rs:750-763) solely to passOutputStart::Content, andend_of_sequence_inside_an_announced_call_is_an_error(dsml.rs:1003-1011) overlapshelios/tests/deepseek_output.rs:387-421(incomplete_calls_do_not_finish_on_eos_and_can_be_cancelled_or_truncated) plusdsml.rs:793.a_truncated_second_call_keeps_the_completed_first_call(dsml.rs:940-960) anda_header_only_call_is_omitted_when_the_response_truncates(dsml.rs:963-984) reuse the exact names ofhelios/src/server/protocol/tests.rs:3894-3961, 3964-4001; theirAccumulatortruncation assertions repeatprotocol/tests.rs.- Simplification: Merge
rejection_testsintostreaming_tests(keepinga_rejected_argument_object_fails_after_its_fragments_are_published), removeend_of_sequence_inside_an_announced_call_is_an_error, and keepdsml.rsfocused onDsmlOutputevent assertions under distinct names rather than repeatingAccumulatortruncation checks.
Nits
ResponseOutput::finishdoes not checkended: false(helios/src/server/output.rs:1733):Accumulator::finish(:165) checks!call.endedandResponseOutput::close(:1722) checksBlock::Tool { ended: false, .. }, whereasResponseOutput::finish(:1733) matchesSome(Block::Tool { .. }). Currently unreachable becauseEvent::ToolEndimmediately callsclose()(:1842-1843), but matchingSome(Block::Tool { ended: false, .. })makes the invariant self-contained.- Extend the end-to-end DSML wire test to Messages and Responses (
helios/src/server/protocol/tests.rs:4004-4073):dsml_arguments_reach_the_chat_wire_while_the_call_is_opencurrently exercisesOutputPipeline→Encoderonly forProtocol::Chat; coveringProtocol::MessagesandProtocol::Responsesas well would pin incrementalinput_json_deltaandresponse.function_call_arguments.deltadelivery end-to-end.
Dropped on verification
- Subtraction candidate ("Delete duplicate
call.check_size()?;athelios/src/output/dsml.rs:191"): Dropped —:191runs beforecall.publish(self.calls, events)at:192. Removing it would allow:192to allocate up to ~1 MiB for the oversized suffix and mutatecall.published_argument_bytesbefore:218-220rejects the call; keeping:191prevents wasted allocation and state mutation on the error path at negligible cost. - Correctness candidate ("
ExecutionErroris the sharpest production path; agent loops cannot distinguish execution failure from empty output"): Dropped/corrected — verified inhelios/src/server/http.rs:562-579andhelios/src/server/runtime.rs:321-329, 2053-2070, 2351-2373that runtime execution errors arrive asGenerationEvent::Error(e)and terminate viaencoder.failure(&e), neverencoder.finish(..., Termination::ExecutionError, ...). Blocker #3 scopes the production impact accurately toUserStop/Cancelled(plus directfinishcallers passingExecutionError). - Correctness candidate ("Fix
#364reversal by reserve-and-check before appending/publishing" and "oversized calls leave the tool block unclosed per F1"): Dropped —dsml.rs:191already checks the size bound before publishing the crossing fragment at:192, and no incremental streaming parser can know ahead of time whether a later token will cross 1 MiB without buffering the full call; furthermore, whencheck_size()errors mid-stream,http.rs:575-579emitsencoder.failure(&e)rather than takingResponseOutput::finish. - Correctness candidate ("
docs/api.md:540-542overreaches by omittingstrict: truetools"): Dropped —docs/api.md:753-755already explicitly documents that Helios buffers strict tool calls until validated and never sends partial strict arguments in streaming responses. - Correctness candidate ("Test-count drift 1783/18 → 1787/16 across content-identical push"): Dropped as low-signal; the concrete verification gap is captured in Blocker #1 (4 failing
helios/tests/integration tests skipped by--lib) and Pre-merge Checks (unbuiltflare/flare-cli). - Subtraction candidate ("
dsml.rs:940, 963are pure duplicates ofprotocol/tests.rs:3894, 3964"): Partially corrected — thedsml.rstests exercise realDsmlOutputparsing rather than syntheticEvents, so only their colliding names and duplicatedAccumulatortruncation assertions were retained under Subtract / Simplify #2.
Full report Decision to Test: no (100%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.
Classify triage
Selected: triage:review
Threshold: 65%
Triage
- [✓]
triage:review: 97.0% -
triage:design-review: 2.9% -
none: 0.0% -
triage:validation: 0.0% -
triage:integration: 0.0% -
triage:partial: 0.0% -
triage:investigate: 0.0% -
triage:superseded: 0.0% -
triage:verify-for-closure: 0.0%
Apply labels
No label changes decide malicious: all_clear (100%): No malicious content found
explore
Author: peperunas (FIRST_TIME_CONTRIBUTOR; prior PR #519 closed unmerged; Discord: peperunas)
Motivation: DeepSeek tool calls arrive all at once when the closing tag is parsed, so a multi-kilobyte write argument leaves the stream silent long enough that clients render a stall or a hung model. The PR makes the DSML parser announce the call at name completion and publish argument fragments as the model writes them.
Scale: +722 / −80 in 15 files
Proposal:
- Emit
Event::ToolBeginatToolNameEndand publish argument bytes per append viaCall::publish/published_argument_bytes(helios/src/output/dsml.rs:38,49-62,145-156,191-206). - Withhold
string="false"values whileclose_literalmay still rewrite them, so no published byte changes (dsml.rs:54,64-78). - Add
drops_unfinished_call(cause) -> cause != Termination::Eosand threadcauseintoAccumulator::finish/ResponseOutput::finish(helios/src/server/output.rs:163-173,478-480). - Render the abandoned tool block's closing frame before dropping it, so Messages/Responses streams still close announced blocks (
output.rs:1731-1755,protocol/encode.rs:677-689). - Update
docs/api.md:540-575, add DSML unit tests and three protocol tests, and edithelios/tests/deepseek_output.rs/deepseek_requests.rsto match streaming. Touches: helios/src/server/output.rs— truncation now drops an announced-but-unfinished call for UserStop/Cancelled/ExecutionError instead of returningserver_error; invertsuser_stop_cannot_retract_an_already_emitted_partial_tool_call.helios/src/output/dsml.rs— publish-before-check_sizereverses #364's pre-publication bound.helios/src/server/protocol/encode.rs— new finish-cause plumbing and abandoned-block rendering. Related items:- #364 Enforce DeepSeek tool call size and retain deeply nested values (merged): its pre-publication 1 MiB bound is reversed.
- #670 Parameterize THINK_TAGS reasoning, add TAGGED_JSON tool parser (merged): makes the new
docs/api.md:543-547false; rebase needed. - #333 Complete responses after one tool call when parallel calls are disabled (merged): supplies the
Cancelleddiscard path this truncation rides on. - #418 Strict function-tool schemas for DSML/Qwen/GLM/TML (merged): its
pending_strict_callsparking is preserved, not changed. - #347 GLM-5.3 production agent-traffic umbrella (open): possible prior report of the silent-tool-call symptom; body unreadable here.
Link: https://github.com/NVIDIA/hyperflare-inference/pull/685
Autobot comments: Only flare-autobot has engaged: intake 18:10, "Changes Requested" reviews at 18:31 and 20:04, both analysing hashes ≤
80c87b3, so headb9864ab(pushed after 20:04) is unreviewed. That push repaired the two blockers (four brokenhelios/tests/cases; unclosed Messages/Responses blocks) but did so by weakening assertions (deepseek_output.rs:515now only "no call ended") and left a new residual: rendering an abandoned custom/grammar tool block throughencode.rs:475-484failsEncoder::finishwith "invalid custom tool arguments", ending the stream in an error — untested. No issue or maintainer request exists, the removal ofErr("incomplete emitted tool call")has no sign-off,docs/api.md:543-547is factually false against main'sTAGGED_JSON, and the PR body's test counts were never refreshed after the push.
Classify intake
Selected: triage:review, bug, performance, enhancement, area:api, model:deepseek-v4, model:deepseek-v4.1
Threshold: 65%
Triage
- [✓]
triage:review: 93.7% -
triage:design-review: 6.0% -
triage:validation: 0.1% -
triage:investigate: 0.1% -
triage:integration: 0.0% -
triage:partial: 0.0% -
none: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Priority
-
none: 76.2% -
priority:P2: 21.8% -
priority:P1: 2.0%
Type
- [✓]
enhancement: 85.2% - [✓]
performance: 83.5% - [✓]
bug: 73.1% -
duplicate: 37.8% -
community: 16.5% -
documentation: 1.0%
Area
- [✓]
area:api: 99.4% -
area:preparation: 9.5% -
area:engram: 1.0% -
area:kernels: 0.5% -
area:selene: 0.5% -
area:rocenante: 0.4% -
area:scheduling: 0.2% -
area:memory: 0.1% -
area:caching: 0.1% -
area:orbit: 0.0% -
area:packaging: 0.0%
Model
- [✓]
model:deepseek-v4: 93.2% - [✓]
model:deepseek-v4.1: 85.2% -
model:gemma4: 1.1% -
model:glm-5.3: 0.6% -
model:qwen3.8-flash-next: 0.6% -
model:inkling-small: 0.3% -
model:qwen3.8-27b: 0.2% -
model:nemotron-3.5-bolt: 0.1% -
model:kimi-k3.1: 0.1% -
model:muse-glimmer: 0.1% -
model:mimo-v2.6: 0.1%
Apply Labels (Intake)
No label changes
Subtraction and simplicity
Lens: Subtraction, Simplicity & Conventions. The diff at head b9864ab (15 files, +722/−80, still labelled triage:review, labels include enhancement/performance) is mostly lean; the streaming core is load-bearing. Four concrete cuts, one convention violation.
Accumulator::finish(cause)threads one boolean through 9 files:helios/src/server/output.rs:163-173, whosecauseis used only viadrops_unfinished_call(output.rs:478-480,cause != Eos). Restorefinish(&self)as onmainand adddiscard_unfinished_call(&mut self); revert ~21finish(Termination::Eos)sites (argument_tags.rs:212,287,334,435,490; chatml.rs:418,650,833,1097; dsml.rs:456,500,567,631,699,789; gemma_call.rs:265 (not opened); minimax_xml.rs:346 (not opened); pipeline.rs:345,492,580,685,738; xtml.rs:464,508; protobuf.rs:1160). AGENTS.md:188-193.- Abandoned-block machinery is over-built:
output.rs:1745-1755two public methods +abandonedfield (:1703) for oneVec::poppair; theindex + 1 == self.blocks.len()guard (:1751) is unreachable andmatches!(blocks.last(), Some(Block::Tool{..}))(:1735) cannot fail whenopen.is_some(). Collapse todiscard_abandoned(&mut self), one trailing call atencode.rs:687-689. - Truncation matrices expressed twice each:
protocol/tests.rs:3979-4017duplicates:3809-3907;dsml.rs:962-984duplicates:917-937. Fold by parameterising the pre-cut; their cause lists are already skewed (:3912-3916lacks ExecutionError,:3982-3986lacks Cancelled). docs/api.md:543-547's "because" clause is false againstmain(TAGGED_JSON, #670) and blocks any rebase; delete it plus the non-normative:550-551sentence.helios/tests/deepseek_output.rs:515was rewritten to accept the new behaviour; AGENTS.md:182-187, 201-207 require withdrawing the accommodation.
Open: whether any maintainer authorised dropping the non-EOS Err("incomplete emitted tool call"); review status of b9864ab; no CI on any hash.
Correctness and contracts
Review of PR #685 at head b9864ab, correctness/contracts/system-consequences lens (static reading; nothing executed, no CI on the branch).
- BLOCKER — truncated
custom/grammar tool call now fails the whole Responses request:Encoder::finishrenders the abandoned block'sChange::Endthrough the custom branch, whichserde_json::from_strs partial JSON with?(encode.rs:475-483, from :677-689); http.rs:575-580 emits an error frame, noresponse.completed, anddrop_abandonednever runs. Untested (new tests use function toollookuponly). - MAJOR — for UserStop/Cancelled/ExecutionError the abandoned item's
response.output_item.donesaysstatus:"completed"with partialarguments(encode.rs:339-346, :381, :486, :513-516; only OutputLimit setsincomplete_itemat :680-683), then vanishes fromresponse.completed. - BLOCKER (authority) — announce at
ToolNameEndand publish per fragment now precedevalidate_arguments/1 MiBcheck_size(dsml.rs:145-156, :191-206 vs main:171-194); rejected/oversized calls reach the client and the pinning tests were rewritten (deepseek_output.rs:514-515, :572-601; output.rs:1264-1274). AGENTS.md:182-187/201-207 require sign-off; none on record, and it reverses #364's publish-after-check property. - MAJOR (docs) — api.md:547-549's unconditional "omitted for every termination other than EOS" is contradicted by the required/named
tool_choiceerror at encode.rs:690-694, which still ends in an error frame. - MAJOR (docs) — api.md:543-547 ("tagged parsers build arguments from parameter syntax … rather than copying the model's text") is false against main's merged tagged_json.rs:17-49,57; this PR edits those exact lines.
- MAJOR (claim) — "ExecutionError included" is unreachable in production: only UserStop/Eos/OutputLimit reach Encoder::finish (http.rs:534-540); errors take http.rs:562→576. Test counts (1787/16, 113, 96) are stale for this head.
- CLEAN: per-request state only (no new locks/queues/shared state), fragment copies bounded by the 1 MiB limit, TTFT sampling excludes tool deltas (latency.rs:114-142), and the earlier Messages/Responses unclosed-block framing bug is genuinely fixed.
Open: whether a truncated custom tool is reachable in served configs; the prior reviews' "Should fix"/"Subtract" items; #347's body unreadable.
Re-review
Recommendation: Changes Requested
The incremental DSML streaming core (DsmlOutput::apply + Call::publish with published_argument_bytes and string="false" literal deferral) is clean, byte-exact, and avoids per-model shared-layer branches, concurrency hazards, or TTFT regressions, and b9864ab fixes the four previously broken helios/tests/ integration tests and the Messages closing-frame order. However, the new Change::End-before-drop path in b9864ab introduces a concrete regression that fails Responses requests (both streaming and non-streaming) whenever a custom tool call is truncated, and the PR still reverses reviewed pre-publication (#364) and non-EOS incomplete-call error contracts across code, tests, and docs without explicit maintainer sign-off (AGENTS.md:182-187, 201-207).
Merge Risk
Level: High
- Direct regression on Responses
customtool truncation (streaming and buffered): RenderingChange::Endfor an abandoned tool block beforedrop_abandonedroutes partial JSON arguments intoEncoder::change's custom-tool JSON/grammar validator (helios/src/server/protocol/encode.rs:475-484, 502-505, 677-689), turning truncated DeepSeek custom-tool calls that succeeded asincomplete/completedonmainintoresponse.failed(streaming) or HTTP 500 errors (helios/src/server/http.rs:575-580, 639). - Unapproved contract reversals across all parsers and protocols:
drops_unfinished_call(helios/src/server/output.rs:163-173, 478-480, 1731-1744) replacesmain's non-EOSErr("incomplete emitted tool call")with silent omission across all tool parsers and wire protocols, while DSML streaming publishesToolBegin/ToolArgumentsprior tovalidate_argumentsand#364's 1 MiB bound (helios/src/output/dsml.rs:145-156, 191-206), accompanied by weakened tests (helios/tests/deepseek_output.rs:514-515,helios/src/server/output.rs:1265-1274) without maintainer approval. - No concurrency, memory, or TTFT regressions: All modified state (
DsmlOutput,Accumulator,ResponseOutput,Encoder) is strictly per-request (helios/src/server/http.rs:358-400);Call::publishslices newly appended bytes within the 1 MiB buffer (withstart >= published_argument_bytespreserved acrossclose_literal), strict-tool parking (encode.rs:585-624) remains intact, andstream_text(helios/src/server/latency.rs:116-142) excludes tool-call deltas so TTFT sampling is unchanged.
Walkthrough
- Incremental DSML publication (
helios/src/output/dsml.rs:38, 49-62, 145-156, 191-206): EmitsEvent::ToolBeginatToolNameEnd, tracksCall::published_argument_bytesand publishesEvent::ToolArgumentsfragments after eachToolCallArgumentsTextappend (keepingstring="false"literals unpublished untilclose_literalsettles them), and flushes remaining bytes plusEvent::ToolEndaftervalidate_argumentsatToolCallArgumentsEnd. - Non-EOS unfinished-call omission and closing-frame order (
helios/src/server/output.rs:163-173, 478-480, 1703, 1731-1755,helios/src/server/protocol/encode.rs:674-689): Addsdrops_unfinished_call(cause) -> cause != Termination::Eos, passescauseintoAccumulator::finishandResponseOutput::finish, emitsChange::End(last)for a truncated trailing tool block beforedrop_abandonedpops it, and omits it from the buffered body. - Mechanical test call-site updates (8 files) & inverted/updated tests: Threads
Termination::Eosintooutput.finish(...)acrossargument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs,pipeline.rs,xtml.rs,runtime_core/protobuf.rs, andserver/runtime/phase_tests.rs; rewritesuser_stop_cannot_retract_an_already_emitted_partial_tool_call(helios/src/server/output.rs:1265-1274) and updates integration tests inhelios/tests/deepseek_output.rs:499-515, 572-601andhelios/tests/deepseek_requests.rs:683-693for incremental DSML events. - New unit tests and API documentation (
helios/src/output/dsml.rs:749-1033,helios/src/server/protocol/tests.rs:3809-4090,docs/api.md:540-574): Adds DSML streaming/split/literal-deferral/truncation/rejection tests, Chat/Messages/Responses truncation and end-to-end DSML→Chat tests, and updatesdocs/api.mdfor 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; 1 MiB parser (
helios/src/output/dsml.rs:22, 42-47, 234-236) and 8 MiB response (helios/src/server/output.rs:119-121, 1830-1832) bounds remain enforced. - [WARN] Charter & value fit: Directly serves the charter's coding-agent/heavy-tool-use vision with no per-model shared-layer branch, but has no linked issue/maintainer request and reverses reviewed
#364pre-publication and non-EOS error invariants without maintainer sign-off (AGENTS.md:182-187, 201-207). - [WARN] Related / duplicate / conflict check: No duplicate PR and no textual merge conflict with
#670(itsdocs/api.mdadditions begin at line 610 onmain), but#670addedTAGGED_JSON(helios/src/output/tagged_json.rs:14-49, 57onmain), makingdocs/api.md:543-547factually false againstmain;#364's pre-publication 1 MiB guarantee is reversed. - [WARN] Tests & verification evidence: No CI run on
b9864ab; self-reported counts in the PR body were run with--libonly (omittinghelios/tests/, which was edited inb9864aband is run unconditionally by.github/workflows/native-serving.yml:63 (not opened), 68), andflare/flare-cliwere not built or tested (docs/design-review.md:180-185).
Blockers
-
Truncated
customtool calls on Responses now fail the entire request instead of being omitted (helios/src/server/protocol/encode.rs:470-485, 502-505, 677-689;helios/src/server/output.rs:1731-1744).- Verified behavior & impact: When a
customtool call (tool.custom == true) is truncated byOutputLimitorUserStop,ResponseOutput::finish(cause)emitsChange::End(last)beforedrop_abandonedpops the block.Encoder::finishrenders thatChange::EndthroughEncoder::change(encode.rs:685), which executesserde_json::from_str(arguments)?(:476-477), checksvalue.get("input").is_some_and(Value::is_string)(:478-480), runsgrammar.validate(...)(:481-483), and checksitem["input"].is_string()(:503-505). Because an abandoned call'sargumentsare empty or partial JSON by construction,Encoder::finishreturnsErr("invalid custom tool arguments: ..."),drop_abandonednever runs, streaming Responses requests fail withresponse.failed(helios/src/server/http.rs:575-580), and non-streaming Responses requests return an HTTP error (http.rs:639). This is a direct regression againstmain, whereDsmlOutputbuffered and discarded incomplete calls so both streaming and buffered Responses requests succeeded cleanly asincomplete/completed. - Fix: Pass whether
Change::End(i)is closing an abandoned block intoEncoder::change(or checkabandoned == Some(i)), skip custom-tool JSON/grammar validation andresponse.custom_tool_call_input.{delta,done}emission for abandoned blocks, and emit only the closingresponse.output_item.donewith"status": "incomplete"before discarding the block. Add a Responses protocol test covering a truncatedcustomtool call for both streaming frames and bufferedresponse().
- Verified behavior & impact: When a
-
Reversal of reviewed pre-publication, size-bound, and non-EOS error invariants without maintainer sign-off (
helios/src/output/dsml.rs:145-156, 191-206;helios/src/server/output.rs:163-173, 478-480, 1265-1274;helios/tests/deepseek_output.rs:514-515;docs/api.md:547-551, 568-572).- Verified behavior & impact: Streaming DSML arguments before
ToolCallArgumentsEndinherently publishesToolBeginandToolArgumentsfragments beforevalidate_argumentsand before subsequent appends cross#364's 1 MiB bound (maindocs/api.md:560andhelios/tests/deepseek_output.rs:511pinned "nothing published before validation/size check";b9864abweakens:515toassert_eq!(parsed.ended, 0)). Separately,drops_unfinished_callreplacesmain's non-EOSErr("incomplete emitted tool call")(pinned bymainhelios/src/server/output.rs:1257-1271,user_stop_cannot_retract_an_already_emitted_partial_tool_call, rewritten here to assert omission) across all tool parsers and wire protocols. UnderAGENTS.md:182-187, 201-207, weakening existing validation/error guarantees — including via accompanying doc and test rewrites — requires an explicit maintainer design decision on record before merging. - Fix: Obtain explicit maintainer sign-off (e.g., from
@yatesdr/@voipmonitor, who reviewed/authored#364and the retraction semantics) recorded on this PR confirming (a) post-publication validation/1 MiB enforcement for streaming DSML calls and (b) non-EOS unfinished-call omission across protocols.
- Verified behavior & impact: Streaming DSML arguments before
Should Fix
-
Responses
response.output_item.donereportsstatus: "completed"with partial JSON arguments for non-OutputLimittruncated calls (helios/src/server/protocol/encode.rs:339-346, 381, 486, 509, 513-516, 680-685).self.incomplete_item = Some(i)is set only whencause == Termination::OutputLimit(encode.rs:680-684). OnUserStop(orCancelled),Change::Endrendersself.item(i, true)with"status": "completed"and partial JSON in bothresponse.function_call_arguments.doneandresponse.output_item.done, right beforedrop_abandoneddeletes that item fromresponse.completed'soutput.- Fix: Set
self.incomplete_item = Some(i)wheneverabandoned == Some(i)(not only onOutputLimit), clearself.incomplete_item = Noneafter thefor change in changesloop, and extend the Responses truncation test to assertstatus == "incomplete"for all non-EOS causes.
-
docs/api.md:547-550states an unconditional truncation-omission rule contradicted bytool_choice: Required | Named(helios/src/server/protocol/encode.rs:690-694).docs/api.md:547-550claims an announced call cut off before completion is omitted and the response reports that termination's finish reason for every non-EOS termination. However, afterdrop_abandoned, if no completed tool call remains andtool_choiceisRequiredorNamed(_),encode.rs:690-694returnsErr("required tool choice was not satisfied: ..."), ending the request in an error frame / HTTP error.- Fix: Qualify
docs/api.md:547-550to note thattool_choice: "required"or a named tool still errors when omitting the truncated call leaves no completed tool call (and add a test pinning the intended behavior).
-
docs/api.md:543-547is factually false againstmainafter#670(TAGGED_JSON).docs/api.md:543-547states that all tagged tool parsers buffer "because they build its arguments from parameter syntax and the declared schemas rather than copying the model's text: values are coerced to declared types, strict container parameters are parsed, and wrapping newlines are trimmed." Onmain,TAGGED_JSON(helios/src/output/tagged_json.rs:14-49, 57,JSON_BODY = true,TRIM_NEWLINES = false) parses the model's JSON object directly without parameter syntax, schema coercion, or newline trimming.- Fix: Delete the over-generalized
"because ... trimmed."clause so line 543-544 states simply:"The tagged tool parsers publish a call only when its envelope is complete."(The per-dialect details are already documented atdocs/api.md:601-638onmain.)
Subtract / Simplify
-
Restore
Accumulator::finish(&self)and remove 8 files of mechanical test churn (helios/src/server/output.rs:163-173;helios/src/server/protocol/encode.rs:674-676; 8 test-only files).Accumulator::finish(&mut self, cause: Termination)usescauseonly to evaluatedrops_unfinished_call(cause), forcing ~25 call sites acrossargument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs,pipeline.rs,xtml.rs,runtime_core/protobuf.rs,server/runtime/phase_tests.rs,dsml.rs, andserver/output.rsto passTermination::Eos.- Simplification: Keep
Accumulator::finish(&self) -> Result<()>unchanged frommain, addpub(crate) fn discard_unfinished_call(&mut self)(4 lines), and call it beforefinish()at the single production site (encode.rs:674-676, plusPresentation::finishatoutput.rs:501-505). This deletes 8 entire files from the diff.
-
Collapse
take_abandoned+drop_abandoned(index)intodiscard_abandoned(&mut self)(helios/src/server/output.rs:1745-1755;helios/src/server/protocol/encode.rs:678, 687-689).ResponseOutput::finishalways setsself.abandoned = Some(self.blocks.len() - 1)and renderingchangesnever mutatesself.blocks, so round-trippingindex: usizeout throughtake_abandonedand back intodrop_abandonedwith the unreachableif index + 1 == self.blocks.len()guard adds surface area without value. Replacetake_abandoned/drop_abandoned(index)with a read accessoris_abandoned(&self, index: usize) -> bool(needed for Blocker #1 / Should Fix #1) plus a singlepub fn discard_abandoned(&mut self)that popsblocksandcallswhenself.abandoned.take().is_some().
-
Fold the duplicated header-only vs mid-argument truncation matrix tests (
helios/src/server/protocol/tests.rs:3809-3907, 3979-4017;helios/src/output/dsml.rs:917-937, 962-984).- Both pairs repeat the same loop/assertion body differing only in whether argument fragments were pushed, and
protocol/tests.rs:3982-3986already drifted by omittingTermination::Cancelledand the closing-frame assertions (:3861-3876). Parameterizing each pair over empty vs non-empty fragments removes ~70 lines and keeps one authoritative cause list.
- Both pairs repeat the same loop/assertion body differing only in whether argument fragments were pushed, and
Nits
- Refresh verification evidence on the current head (
b9864ab): Re-run the fullheliostest suite without--lib(covering the editedhelios/tests/deepseek_output.rsandhelios/tests/deepseek_requests.rs), plusflareandflare-cliperdocs/design-review.md:180-185, and update the PR body's test counts.
Dropped on verification
- Subtraction #2 sub-claim that
matches!(self.blocks.last(), Some(Block::Tool { .. }))athelios/src/server/output.rs:1735is dead whenself.open.is_some(): False.self.opentracks openBlock::TextandBlock::Reasoningblocks as well asBlock::Tool(output.rs:1781, 1814); deleting theBlock::Toolcheck would erroneously abandon and drop the final text or reasoning block onOutputLimit/UserStop. - Correctness F8 ("MAJOR:
ExecutionError includedoverstates live coverage"): Over-flagged. The PR description accurately states that the predicatedrops_unfinished_call(cause)holds for every cause exceptEos,ExecutionErrorincluded; it does not claimhttp.rsroutesGenerationEvent::ErrorthroughEncoder::finish(http.rs:562, 576routes runtime errors toencoder.failuredirectly). - Upstream dossier/lens claim that
b9864abaddedmod streaming_tests,mod rejection_tests, and the three protocol tests (making test counts stale specifically due to those modules): Inaccurate. Prior review walkthroughs confirm those modules were already present at2f0ed9dand80c87b3;b9864abadded only thehelios/tests/updates and the closing-frame fix/assertions. - Unmodified
helios/tests/deepseek_requests.rs:404(events.contains(ToolArguments { text: "{}" })) check: Verified safe — that test uses a zero-parameter<|DSML|invoke name="lookup"></|DSML|invoke>, so"{}"is still published as a singleEvent::ToolArgumentsatToolCallArgumentsEnd. - Upstream
docs/api.md:550-551deletion suggestion ("A client that received fragments of such a call has already seen a call that cannot complete"): Low-signal prose preference; kept out ofSubtract / Simplifybecause explicitly documenting the streaming-vs-buffered divergence is genuinely helpful to API consumers once maintainers approve the contract.
Classify triage
Selected: (none)
Threshold: 65%
Triage
-
triage:review: 56.1% -
triage:design-review: 43.7% -
none: 0.1% -
triage:validation: 0.0% -
triage:partial: 0.0% -
triage:integration: 0.0% -
triage:investigate: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Apply labels
No label changes Decision to Test: no (100%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with. decide malicious: all_clear (100%): No malicious content found
explore
Author: peperunas (FIRST_TIME_CONTRIBUTOR; prior PR #519 closed unmerged; Discord: peperunas)
Motivation: DeepSeek tool calls were handed to the client in one burst only after the call's closing tag, so a multi-kilobyte write argument left the stream silent and agents could not tell a working request from a hung one. The PR instead announces the call when its name completes and publishes argument bytes as the model writes them, and it also drops a call that a truncated generation never finished instead of failing the request.
Scale: +871 / −66 lines in 7 files
Proposal:
- Move
Event::ToolBegintoToolNameEndand publish argument fragments through a newCall::publishcursor, keepingstring="false"literals private until settled. - Drop an announced-but-unfinished call for every non-EOS cause via
drops_unfinished_call, withResponseOutputreporting abandoned blocks so the closing frame is still rendered. - Report a truncated custom call as an
incompleteitem with empty input instead of failing the request. - Add ~423 lines of protocol tests and ~303 of DSML tests, and rewrite
docs/api.md's tool-call streaming section. - Ask maintainers whether the non-EOS omission and the post-publication 1 MiB bound are acceptable. Touches:
helios/src/output/dsml.rs(parse-time streaming and the 1 MiB bound ordering)helios/src/server/output.rsandhelios/src/server/protocol/encode.rs(termination semantics on all three wire protocols)docs/api.md(the documented parser contract) Related items:- #364 Enforce DeepSeek tool call size and retain deeply nested values (merged): its pre-publication 1 MiB bound is reversed.
- #670 Parameterize THINK_TAGS, add TAGGED_JSON parser (merged): stale
docs/api.mdparagraph now rescoped. - #102 Consult ignore_eos when classifying a finish reason (merged): accepted precedent for omitting a truncated call at OutputLimit.
- #679 Output-layer stream failures counted as cancellations (closed): endorses
server_errorfor rejected streamed calls, which this PR removes in one case. - #519 Park an Engram gather while it waits for device-published ids (closed): author's only prior PR, unmerged.
Link: https://github.com/NVIDIA/hyperflare-inference/pull/685
Autobot comments: Head is now
826a427a(7 files, was 15). Two of my earlier blockers are repaired: the truncated custom-tool call no longer errors (encode.rs:470-491), and thedocs/api.mdparagraph falsified by #670 is rewritten. The eightfinish(Termination::Eos)call-site edits and theAccumulator::finishsignature change are reverted, so the churn criticism no longer applies. The universal behaviour change does not go away: it now lives inEncoder::finish(encode.rs:681-686) and still omits the call for UserStop/Cancelled/ExecutionError in every parser and protocol. The repair of the fourhelios/tests/failures was done by weakening the assertion athelios/tests/deepseek_output.rs:515toparsed.ended == 0, whichAGENTS.md:182-187, 201-207forbids. Nothing was executed here and no CI run exists on any hash; the live 566-frame measurement is the author's own.
Classify intake
Selected: performance, enhancement, area:api, model:deepseek-v4, model:deepseek-v4.1
Threshold: 65%
Triage
-
triage:review: 53.0% -
triage:design-review: 46.7% -
none: 0.1% -
triage:validation: 0.1% -
triage:partial: 0.0% -
triage:integration: 0.0% -
triage:investigate: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Priority
-
none: 67.9% -
priority:P2: 28.3% -
priority:P1: 3.8%
Type
- [✓]
enhancement: 88.1% - [✓]
performance: 83.5% -
bug: 59.3% -
community: 37.8% -
duplicate: 11.9% -
documentation: 1.6%
Area
- [✓]
area:api: 99.8% -
area:memory: 2.9% -
area:preparation: 2.6% -
area:caching: 2.0% -
area:engram: 1.0% -
area:kernels: 0.8% -
area:selene: 0.3% -
area:rocenante: 0.2% -
area:scheduling: 0.2% -
area:orbit: 0.1% -
area:packaging: 0.1%
Model
- [✓]
model:deepseek-v4: 94.7% - [✓]
model:deepseek-v4.1: 93.2% -
model:qwen3.8-flash-next: 4.7% -
model:nemotron-3.5-bolt: 0.8% -
model:qwen3.8-27b: 0.7% -
model:kimi-k3.1: 0.2% -
model:glm-5.3: 0.2% -
model:inkling-small: 0.2% -
model:mimo-v2.6: 0.1% -
model:gemma4: 0.1% -
model:muse-glimmer: 0.0%
Apply Labels (Intake)
No label changes
Subtraction and simplicity
Subtraction & Simplicity audit — PR #685 @ 826a427a
Verdict: the production diff is small (≈90 changed lines across dsml.rs, output.rs, encode.rs) and mostly justified, but it is not lean: the same "was this call truncated?" fact is encoded three times in three files, dsml.rs keeps a hand-maintained ordering that a one-line helper change makes unrepresentable, and +738 of the +871 added lines are tests in which the same five-element termination matrix and the same DSML envelope fixture are hand-copied between files, including a duplicated test name. Everything below is verified at head unless labelled main.
1. Subtraction — one fact, three carriers ("abandoned")
The PR introduces a third representation of one boolean. All three live simultaneously on the truncation path:
helios/src/server/output.rs:1707—abandoned: Option<usize>onResponseOutput, plusis_abandoned(:1752-1754) anddiscard_abandoned(:1757-1762), with a doc comment explaining a two-phase lifecycle: "The block stays present untildiscard_abandoned."helios/src/server/protocol/encode.rs:687let mut abandoned = false;/:698abandoned |= truncated;/:705-707if abandoned { self.incomplete_item = None; }helios/src/server/protocol/encode.rs:158incomplete_item: Option<usize>(pre-existing onmain:158), read initemat:340.
So the encoder asks is_abandoned (:694), remembers the answer in a local, then sets and immediately clears incomplete_item. The comment at :703-704 admits why: "The buffered response is rendered after this returns, so the marking outlives the change that set it unless the item is gone." That is a description of a leaked intermediate, not of a contract.
Concrete simplification: let the change carry the outcome. Change::End(usize) → Change::End(usize, Outcome) (Complete / Incomplete / Abandoned) is a one-variant addition to a 3-variant private enum (output.rs:1697-1701). Then:
item(i, complete)derives its status from the outcome it is already passed (:339-346), andincomplete_itemdisappears entirely (4 sites:158,218,340,696/706);- the
abandonedlocal and the|=/clear dance at687/698/705-707disappear; is_abandoned+discard_abandonedcollapse to "drop the block if the outcome isAbandoned", since the outcome is already in hand at:471.
That is ~25 lines removed and one invalid state (incomplete_item set for a block that no longer exists — exactly what :705-707 exists to paper over) made unrepresentable.
Bug the collapse exposes (worth fixing in the same edit): incomplete_item is a single Option on the Encoder, but the loop at :688 runs per choice and self.outputs is Vec<ResponseOutput> (:140, (0..choices) at :196). Clearing incomplete_item at :705-707 for choice k also clears the marking set for choice j < k, and a later choice's item(i, …) renders status completed for the earlier choice's truncated block. The field being per-encoder and per-choice simultaneously is the invalid state; making the outcome travel with the change removes it.
2. Simplicity — publish should own check_size
helios/src/output/dsml.rs now calls the same two functions in the same order at three sites:
:191-192call.check_size()?;/call.publish(self.calls, events);:201-203call.check_size()?;/call.publish(self.calls, events);:218-220(loop tail)if let Some(call) = &self.call { call.check_size()?; }
publish (:53-62) already mutates self and already early-returns, so the invariant "enforce the 1 MiB bound, then publish whatever is now storable" belongs inside it:
fn publish(&mut self, index: usize, events: &mut Vec<Event>) -> Result<()> {
self.check_size()?;
if self.literal.is_some() || self.published_argument_bytes == self.arguments.len() {
return Ok(());
}
...
}
Three call sites become one call each, and the ordering documented at docs/api.md:573-576 ("enforced on the append that crosses it, after the call name and earlier argument fragments were published") becomes structural rather than a comment three readers must keep in sync. This is exactly the post-publication bound the PR is asking maintainers to bless — making it a single line is what the review question at the end of the body should be resting on.
3. Simplicity — custom is computed twice to be un-combined once
helios/src/server/protocol/encode.rs:471-491:
let abandoned = self.outputs[0].is_abandoned(i);
let custom = matches!(&self.outputs[0].blocks[i], Block::Tool { name, .. } if self.tool(name).is_some_and(|tool| tool.custom));
if !abandoned && let Block::Tool { name, arguments, .. } = &self.outputs[0].blocks[i] && custom
{ /* parse + grammar */ }
…
let complete = !(abandoned && custom);
let item = self.item(i, complete);
custom is matched out of blocks[i] at :472, then matched again at :474-476 only to reach arguments, and the two booleans are recombined at :490. One match yields both, and the whole guard becomes the match arm:
match (&self.outputs[0].blocks[i], abandoned) {
(Block::Tool { name, arguments, .. }, false) if self.tool(name).is_some_and(|t| t.custom) => { /* parse + grammar */ }
_ => {}
}
The let-chains version also hides that abandoned && custom is the only combination where complete is false — with the tuple match that is visible in the arm pattern instead of in a !(a && c) expression.
4. Simplicity — blocks.last() where self.open is the answer
helios/src/server/output.rs:1737-1745:
if drops_unfinished_call(cause)
&& self.open.is_some()
&& matches!(self.blocks.last(), Some(Block::Tool { .. }))
{
let last = self.blocks.len() - 1;
changes.push(Change::End(last));
self.abandoned = Some(last);
self.open = None;
}
self.open is the index of the last block by construction (:1821 self.open = Some(i); where i == self.blocks.len(), and every close sets it to None). The blocks.last() test and the len() - 1 re-derivation are a second, weaker way to ask the same question — and they disagree in the case that matters: a Block::Tool at last that is already ended with self.open == Some(text_block). Use let Some(last) = self.open.filter(|&i| matches!(self.blocks[i], Block::Tool { .. })) and both the is_some() check and the subtraction go away.
5. Duplication in the tests — the bulk of the diff
a. The termination matrix is spelled out five times, differently each time. [OutputLimit, UserStop, ExecutionError] at dsml.rs:928-933 and :961-965; [OutputLimit, UserStop, Cancelled, ExecutionError] at protocol/tests.rs:3849-3854; [OutputLimit, UserStop, Cancelled] at :3965-3969; [OutputLimit, UserStop] at :4103. The PR body claims the tests "hold the truncation matrix as one table per property" — there is no table; there are five hand-written literals. Static const CAUSES: [Termination; 4] (or one helper for_each_truncation(f)) makes the claim true and the matrix greppable in one place.
b. The same test name exists twice. a_truncated_second_call_keeps_the_completed_first_call at dsml.rs:956 and protocol/tests.rs:3960. The dsml.rs copy drives parser + Accumulator + discard_unfinished_call by hand; the tests.rs copy drives the encoder for all three protocols. Only the encoder copy is needed once item 1 lands — the parser-level one re-tests Accumulator internals that the encoder test already covers end-to-end.
c. The DSML envelope fixture is built three different ways: dsml.rs:765-767 (envelope), protocol/tests.rs:4056 (inline literal let wire = "…"), helios/tests/deepseek_output.rs:166-175 (block). Three copies of a markup dialect that is already in helios/tests/support/.
d. for event in push { parsed.event(event) } boilerplate, four times: deepseek_output.rs:503-506, :581-582, :588-589, :593-594. A fn feed(&mut self, out: &mut OutputPipeline, text: &str) -> Result<()> on Parsed removes all four — and would have let the old assertions stay (see note below).
Note on that rewrite: the change at deepseek_output.rs:515 (assert!(published.is_empty()) → assert_eq!(parsed.ended, 0, "a rejected call reported an end")) and at :581-595 (empty-push assertions dropped) is the one place where simplification was used to weaken a test rather than to remove a line. Parsed cannot distinguish "no ToolBegin was published" from "a ToolBegin was published", so routing events through it was the only way to keep the new behaviour green. If the requirement is that a rejected call publishes nothing usable, Parsed needs a began: usize counter and the assertion should be assert_eq!((parsed.began, parsed.ended), (0, 0)). That keeps the original strength at the same line count.
6. Docs
docs/api.md:540-559 newly restates the cause→finish-reason mapping (:549-550 "a response that completes reports the termination's finish reason; only an output-limit termination reports the output limit") that the same file already states at :584-590. Two places to edit for one rule. Keep the truncation sentence at :547-552 and delete the redundant clause; also :554 has a missing wrap — …error event for streams. A client that received fragments… exceeds the paragraph width every other line in the file respects.
Explicitly not a finding
drops_unfinished_call (helios/src/server/output.rs:477-481, cause != Termination::Eos) is a one-line function, but it names a policy decision that three call sites (encode.rs:682, encode.rs, output.rs:1737) share and that the PR is asking maintainers about. That is a legitimate name, not a wrapper to inline.
Lean-ness summary
| area | added | verdict |
|---|---|---|
dsml.rs production (~25 lines) |
justified, 2 simplifications (#2) + 1 subtraction (#3-adjacent) | |
output.rs production (~35 lines) |
3 representations of one fact (#1), last() misuse (#4) |
|
encode.rs production (~45 lines) |
#1, #3 | |
tests.rs +423, dsml.rs tests +303 |
matrix duplicated 5×, one duplicate test name, fixture triplicated (#5) | |
docs/api.md +29 |
restates :584-590 (#6) |
Fixing #1 and #2 removes ~25 production lines and closes a real cross-choice status bug; folding the test matrices removes another ~40; nothing else in the diff is speculative generality or dead code.
Gates and contracts
Contracts, Charter & Verification Gates Audit — PR #685
Head audited: 826a427a (pr_files: 7 files, +871/−66). Read-only audit: nothing was executed and no GitHub check-run API is available here; every statement below is from the diff at head, main, and the governance docs.
Verdict: one hard-gate violation family (Gate 1 + Charter), in two concrete parts. Gates 2, 3 and 4 pass.
Gate 1 — Signed core-format / wire / captured-graph / public-contract boundaries
Mechanical prongs: PASS. No protobuf, no core-format or captured-graph enum, no new graph operation family, no wire kind, no new configuration switch or environment variable. The changed files are docs/api.md, helios/src/output/dsml.rs, helios/src/server/output.rs, helios/src/server/protocol/{encode,tests}.rs, and two helios/tests/ files. Event/Termination on main (helios/src/output.rs:54,61) already carry ToolBegin/ToolArguments/ToolEnd; the PR re-times their emission and adds no variant. docs/core-design.md / docs/scheduling-theory.md (not opened) / docs/scheduling-runtime-design.md (not opened) / docs/core-format-design.md (not opened) are untouched, and the one core-design invariant in this area — "The output encoder holds the call until it has validated the complete arguments; a truncated strict call does not publish partial arguments" (docs/core-design.md:1731-1732, :1697 at head) — is preserved, since strict calls keep the pending_strict_calls parking path (helios/src/server/protocol/encode.rs:577-631).
Normative-doc prong: PASS. The contradicted normative document is updated inside the PR: docs/api.md:580-582 on main ("The model parsers buffer tool envelopes until they are complete, so argument events do not imply incremental generation of an unfinished call") becomes docs/api.md:540-559 and :561-578 at head. The earlier round's factual defect is also genuinely repaired: the false "because they build its arguments from parameter syntax …" clause is gone (docs/api.md:545-547), so nothing in the changed prose is false against main's TAGGED_JSON (helios/src/output/tagged_json.rs:14-66).
BLOCKER 1 — the PR reverses two reviewed normative invariants before obtaining the maintainer decision it asks for (AGENTS.md:182-187, 201-207)
Both reversals are real, and both were previously attested as contracts by the people the PR addresses:
- #364's pre-publication 1 MiB / key-validation bound.
mainstates "Helios rejects a larger call before publishing it" (docs/api.md:600); #364's reviewer recorded the property explicitly — "The size check now runs after the final value is quoted and the closing text appended, before any event is published" (read_item(364), yatesdr review, 2026-11-18 23:54). At head,helios/src/output/dsml.rs:151-155publishesEvent::ToolBeginatToolNameEndand:191-192publishes fragments per text append, socheck_size(:191) andvalidate_arguments(:202) now run after publication;docs/api.md:574-576documents exactly that ("enforced on the append that crosses it, after the call name and earlier argument fragments were published and are not retracted"). - The non-EOS incomplete-call error.
mainreturnsErr("incomplete emitted tool call")atAccumulator::finish(helios/src/server/output.rs:165) andResponseOutput::close(:1728), pinned byuser_stop_cannot_retract_an_already_emitted_partial_tool_call(renamed and inverted athelios/src/server/output.rs:1269-1278). Head addsdrops_unfinished_call(cause) = cause != Eos(helios/src/server/output.rs:479-481), calls it fromEncoder::finish(encode.rs:681-686) andResponseOutput::finish(output.rs:1735-1748) so UserStop/Cancelled/ExecutionError now succeed, and rewrites the rule atdocs/api.md:547-554.main's documented rule was scoped to the output limit ("Truncated tool envelopes are omitted and the response reports its output limit",docs/api.md:582-583); the PR generalises it to every non-EOS cause across all parsers and all three protocols, while the streaming benefit is DSML-only.
AGENTS.md is unambiguous that this is a prior decision, not a review-time one: "Resolve conflicts through an explicit maintainer decision on the design before implementing a change to that invariant" (AGENTS.md:204-207), and the criteria apply "to documentation and test changes that would weaken the rules as well as code" (:201-207). The PR body does disclose both reversals and asks @voipmonitor and @yatesdr to accept them — that is honest disclosure, but it is not the recorded decision the rule requires, and pr_comments shows no human comment or review in the entire thread (three Autobot reviews, plus the author's two pings). The change is therefore implemented ahead of its authorisation.
Mitigating context to weigh, not a waiver: omission at OutputLimit was accepted precedent in #102, and docs/api.md:552-554 does disclose the tool_choice: required/named exception that encode.rs:708-711 implements. That narrows the delta to UserStop/Cancelled/ExecutionError — but the delta is still unratified.
BLOCKER 2 — an existing guarantee assertion was deleted to make the suite pass (AGENTS.md:182-187, 201-207)
helios/tests/deepseek_output.rs:515: main's assert!(published.is_empty()) after a duplicate/empty-parameter rejection is replaced by assert_eq!(parsed.ended, 0, "a rejected call reported an end"), and parse_literal_parameters (:576-592) likewise stops asserting that nothing is published, routing the events into Parsed instead. The check that a rejected call published nothing — precisely the #364 property in Blocker 1 — is removed rather than the behavior being justified. This is the case AGENTS.md names verbatim: "Do not remove validation, suppress errors, … to obtain passing checks", applied to test changes. It needs the same maintainer decision as Blocker 1, or the assertion should stay and the behaviour change should wait.
These two are one governance finding: the wire-visible contract reversals and the test weakening that accompanies them must either be approved on the record by the #364 owner/reviewer or be dropped from this PR.
Gate 2 — Vendored upstream dependencies & cross-PR conflicts: PASS
- No vendored file is touched.
helios/native/roce_proxy.c(not opened) and the rest ofhelios/native/are absent from the diff. - No dependency is added, changed or unpinned:
helios/Cargo.toml:35-37pinsdeepseek-recipe*torev = "70be62f30c64400229fcdb233a7f19a03a5e8ed6"identically onmainand at head, and noCargo.toml/Cargo.lockappears inpr_files. The DSML action stream the PR re-times (ToolNameEnd,LabelToolCallArguments,ToolCallArgumentsText,ToolCallArgumentsEnd) is consumed from that pinned dependency, unchanged. - Cross-PR conflicts are textual only and non-blocking:
#670'sdocs/api.mdadditions sit further down the file and itsdsml.rschanges are ingrammar_envelope; the semantic staleness#670introduced is already fixed at head (docs/api.md:545-547). No dependency on an unmerged recipe or external PR.
Gate 3 — Mandatory verification evidence: PASS (one Info note)
- No GPU/CUDA/VMM execution path, scheduler, cache or worker lifecycle is touched. The diff is confined to the parser and the per-request HTTP encoder/accumulator.
- Layer 3 is not triggered for the changed state.
docs/design-review.md:214requiresverification/helios-lifecycle/check.pyfor changes to "response buffering or ownership"; the changed type is HTTP-encoder state, whichverification/helios-lifecycle/README.md:142explicitly places outside the TLA+ projection ("HTTP encoder state is outside the TLA+ projection"), and the model-level producer/reader contract the harness checks is untouched. The corresponding harness test still exists and is unaffected (verification/helios-lifecycle/check.py:335-337→helios/src/server/runtime/response_lifecycle_tests.rs:332(not opened)). Info: if maintainers readAccumulator/ResponseOutputas within "response buffering",check.pywould need a run; nothing inResponseLifecycle.tlacurrently models block or call ordering, so I do not treat this as a violation of the rule as written. - No performance speedup is claimed. The claim is frame-arrival timeliness (2 frames → 566 for a 2.2 KB
write), which is a UX/latency-of-first-argument observation, not a throughput claim, so nomain-vs-branch served-workload A/B benchmark is required by Layer 3. I flag the measurement's provenance only as a limitation already visible in the body (author's own endpoint, one model). - Layer 1 evidence is present and honestly reported. The body reports the exact CI command (
cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --no-fail-fast), 1848 passed / 20 failed / 84 ignored on head, the same command at the branch point1fbcc3c9giving 1776/17 plus 3message_boundariesfailures, andflare/flare-cliat 254/245 passed. Per the calibration rule I do not flag the absence of an observable CI run. The 20 failures are disclosed, attributed to environment (RLIMIT_MEMLOCKfor eleven engram tests; missingFLARE_TEST_TEMPLATE_DIRfor nine chat-template tests — the workflow supplies that variable,.github/workflows/native-serving.yml:59 (not opened),67,72,76,80), and the branch-point comparison establishes they are pre-existing rather than caused here. No gate-3 violation.
Gate 4 — Material scope / claim contradictions: PASS (two Info notes)
No unrelated standalone tooling, no bundled refactor, no scope expansion; 871 lines are dominated by tests (protocol/tests.rs +423, dsml.rs streaming/rejection tests +303).
- Info: the body's "drives a truncated custom call and a truncated function call on all three wire protocols and every termination cause" overstates the custom-call matrix.
a_truncated_custom_call_closes_incomplete_without_failing_the_request(helios/src/server/protocol/tests.rs:4102-4145) is Responses-only and coversOutputLimit/UserStoponly;a_truncated_second_call_keeps_the_completed_first_call(:3960-3966) omitsExecutionError. The function-call matrix does run all three protocols × four non-EOS causes (:3844-3901), so the tests exist — this is imprecise wording about coverage, not a fabricated check, and does not meet the "major contradiction" bar. - Info:
docs/api.md:554-555("A client that received fragments of such a call has already seen a call that cannot complete") is commentary rather than a normative statement; harmless, but it is the only place the streaming/buffered divergence for a truncated Chat call is implied rather than specified.
Recommendation
Changes requested on Gate 1 alone. Everything mechanical about this PR is clean: no proto, core-format, captured-graph, wire-kind, vendored-file, dependency or scope violation, and the Layer-1 evidence is disclosed with a branch-point baseline. What blocks it is authority: it reverses two invariants that are documented in main and were attested by #364's author and reviewer — #364's publish-after-check bound and the non-EOS incomplete emitted tool call error — and deletes the assertion that pinned the first (helios/tests/deepseek_output.rs:515), all before the maintainer decision the body itself requests exists. Either obtain and record that decision from @voipmonitor/@yatesdr (making the doc rewrite and test change legitimate), or split the truncation/validation-ordering change out and land the DSML streaming re-timing on its own.
Code correctness
Deep Code Correctness, Invariants & Hot-Path Performance Audit — PR #685 @ 826a427
Scope/partitioning: 7 files, ~871 net changed lines, single crate (helios). Below the >12-file / >900-line multi-crate threshold, so audited directly (no sub-agents).
Verdict: the PR's core streaming invariants are correct. I found one Major hot-path defect (O(N²) delta coalescing, newly reachable because of this PR) and one Minor cross-protocol inconsistency (Anthropic Messages renders a truncated DSSM call as a completed zero-input tool_use block). The remaining mechanical checks pass; details of what I verified and why it is sound are at the end.
Finding 1 — Major (hot path): per-fragment publishing turns Accumulator::apply into O(N²) coalescing on the Chat wire
Diff site: helios/src/output/dsml.rs:173-193 (new publish on every argument-text action) and helios/src/output/dsml.rs:53-62 (Call::publish).
Callee: helios/src/server/output.rs:113-141.
// helios/src/output/dsml.rs:53-62
fn publish(&mut self, index: usize, events: &mut Vec<Event>) {
if self.literal.is_some() || self.published_argument_bytes == self.arguments.len() {
return;
}
events.push(Event::ToolArguments {
index,
text: self.arguments[self.published_argument_bytes..].to_owned(),
});
self.published_argument_bytes = self.arguments.len();
}
// helios/src/server/output.rs:113-141
Event::ToolArguments { index, text } => {
let call = self.calls.get_mut(index).filter(|call| !call.ended)
.ok_or("tool arguments require an open call")?;
if call.arguments.len().saturating_add(text.len()) > 8 * 1024 * 1024 { ... }
call.arguments.push_str(&text);
if let Some(previous) = deltas.last_mut()
.and_then(|v| v.get_mut("tool_calls"))
.and_then(Value::as_array_mut)
.and_then(|calls| (calls.len() == 1).then(|| &mut calls[0]))
.filter(|call| call["index"].as_u64() == Some(index as u64))
{
let args = previous["function"]["arguments"]
.as_str().unwrap_or("").to_owned() // <-- full copy of accumulated text
+ &text;
previous["function"]["arguments"] = Value::String(args);
} else { ... }
}
Why this PR makes it a hot-path defect. Before the PR, DsmlOutput::apply emitted exactly one ToolArguments carrying the whole argument object at ToolCallArgumentsEnd (pr_diff removed block: Event::ToolArguments { index, text: call.arguments }). The coalescing branch in Accumulator::apply therefore ran at most once per call — harmless. Now Call::publish pushes a fragment for every ToolCallArgumentsText action, i.e. once per decoded chunk/token of argument text. Each fragment hits the coalescing branch, and each hit does args.to_owned() + &text, a full copy of everything accumulated so far.
Concrete counterexample (matches the PR's own measurement). A write call with a 2.2 KB argument produced 566 frames (PR description). With ~566 fragments and average accumulated length ~1.1 KB:
- total bytes copied ≈ Σᵢ 1 100·i ≈ 566²/2 · 1.1 KB ≈ 176 MB of memcpy per tool call, plus 566 heap reallocations of the growing
String; - at the documented 8 MiB argument ceiling (
helios/src/server/output.rs:119) with ~2 000 fragments, copied bytes ≈ (2 000²/2)·4 KB ≈ 8 GB for one call, on the request's streaming path, per choice.
This is quadratic in the number of published fragments and bounded only by the 8 MiB argument cap, so a single large tool call regresses from O(total bytes) to O(N²) on the hot per-token path. Note the PR description also confirms a multi-kilobyte write argument is the motivating real workload.
Fix (local, keeps the coalescing optimization): make the merge amortized O(1) instead of re-copying — e.g. push a fresh delta value and let the serializer concatenate, or track the index of the last tool-call delta and mutate a Vec<Value>-free buffer; simplest correct form:
if let Some(previous) = /* ...same navigation... */ {
let slot = &mut previous["function"]["arguments"];
match slot {
Value::String(s) => s.push_str(&text), // in-place, amortized O(1)
_ => *slot = Value::String(text.to_string()),
}
} else { /* push new delta */ }
serde_json::Value::String derefs to String, so push_str amortizes to O(1) per fragment and the whole call becomes O(total bytes). (Alternative: have Call::publish coalesce fragments up to a size threshold — but the Accumulator fix also protects the other streaming parsers and is strictly better.)
Finding 2 — Minor (cross-protocol inconsistency / silent wrong behavior): a truncated call becomes a completed zero-argument tool_use block on the Messages wire
Diff site: helios/src/server/protocol/encode.rs:679-707 (new drops_unfinished_call / discard_abandoned gating) with no corresponding Messages handling, contrasted against helios/src/server/protocol/encode.rs:470-491 (Responses is_abandoned → status: "incomplete").
Callee: helios/src/server/protocol/encode.rs:390-404 (anthropic_block), helios/src/server/output.rs:1735-1762.
// helios/src/server/output.rs:1735-1748
pub fn finish(&mut self, cause: Termination) -> Result<Vec<Change>> {
let mut changes = vec![];
if drops_unfinished_call(cause)
&& self.open.is_some()
&& matches!(self.blocks.last(), Some(Block::Tool { .. }))
{
let last = self.blocks.len() - 1;
changes.push(Change::End(last)); // Messages -> content_block_stop
self.abandoned = Some(last);
self.open = None;
}
self.close(&mut changes)?;
Ok(changes)
}
// helios/src/server/protocol/encode.rs:408-414 (Change::Start, Messages)
(Protocol::Messages, Change::Start(i)) => {
let block = self.anthropic_block(i, false); // arguments "" -> input json!({})
frames.push(self.named("content_block_start",
json!({"index":i,"content_block":block})));
}
// helios/src/server/protocol/encode.rs:396-403
Block::Tool { id, name, arguments, .. } => { json!({"type":"tool_use","id":id,"name":name,
"input": if complete { serde_json::from_str::<Value>(arguments).unwrap_or(json!({})) }
else { json!({}) }}) }
Why it is a defect. ResponseOutput::finish emits Change::End(last) for the abandoned block on all protocols; only Responses consults is_abandoned (encode.rs:471) to downgrade the item to status:"incomplete". For Protocol::Messages the same Change::End is turned into a plain content_block_stop (encode.rs:424-429), and the block itself was announced earlier as content_block_start with input: {}. The block is then popped by discard_abandoned() (encode.rs:702), so self.response()["content"] is empty (encode.rs:833), but the streaming client has already received:
content_block_startwith{"type":"tool_use","id":"...","name":"write","input":{}}- any number of
input_json_deltafragments (encode.rs:416-423) content_block_stop— the Anthropic terminal frame for a valid, complete tool_use block
Anthropic clients treat content_block_stop as "this tool_use is complete" and execute it with the accumulated partial-JSON merge; here the merged input is {} (no complete flag ever reaches anthropic_block on the End path, and no partial_json terminator is sent). Contrast the Responses path, which the PR explicitly fixed to report incomplete and to skip the custom-input frames (encode.rs:488-514). So for Messages a UserStop/OutputLimit/Cancelled truncation silently yields an executable write call with empty arguments — the precise class of bug the PR set out to eliminate on Chat/Responses.
The PR description acknowledges only the Responses and Chat contracts; the Messages wire is left with a "completed empty call" semantics that is not documented in docs/api.md either.
Concrete counterexample. Protocol::Messages, DSML parser, stream "<|DSML|tool_calls><|DSML|invoke name=\"write\"><|DSML|parameter name=\"path\" string=\"true\">a.txt", terminated with Termination::UserStop. Emitted: content_block_start {tool_use, input:{}}, content_block_delta {input_json_delta, partial_json:"{\"path\": \"a.txt\""}, content_block_stop. A Messages client merging the deltas issues write({"path": "a.txt"}); a client using the announced input issues write({}). The PR's own test an_announced_call_is_omitted_when_the_response_truncates (helios/src/server/protocol/tests.rs:3842-3930) asserts only that a content_block_stop exists for Messages and never checks that the block is distinguishable from a completed one — so the matrix does not catch this asymmetry.
Fix. Give Messages the same abandonment signal Responses got: either (a) suppress Change::Start/Delta for tool blocks whose arguments are known-incomplete, or (b) tag the content_block_stop path with self.outputs[0].is_abandoned(i) and emit the block's content_block_start-announced input only after completion — at minimum, do not emit a content_block_stop for a block that will be discarded, and extend helios/src/server/protocol/tests.rs to assert response()["content"] and the absence of a terminal content_block_stop for the abandoned Messages block (the current assertion at tests.rs:3921-3928 requires the stop frame, which locks in the wrong behavior).
Verified-clean checks (no defect found)
-
Call::publishprefix invariant (dsml.rs:53-62).published_argument_bytesonly ever advances toarguments.len()insidepublish, andclose_literal(dsml.rs:65-78) can only rewrite in place the slice starting atliteralwhileliteral.is_some()blockspublish. I traced every mutation ofarguments:LabelToolCallArguments(dsml.rs:165push_str, setsliteral = Some(len)forKeyValueSeparator),ToolCallArgumentsText(dsml.rs:180/189push_strthencheck_sizethenpublish), andToolCallArgumentsEnd(dsml.rs:200push_str(closing_text)). Hencepublished_argument_bytes ≤ literal_startalways, solive = arguments[published..]never contains a byte thatclose_literalcan replace — the "no published byte is replaced" claim holds. Thestring="false"path is safe becauseLabelToolCallArguments(ArgumentSeparator)callsclose_literal()before appending the separator (dsml.rs:162-165), andToolCallArgumentsEndcalls it beforeclosing_text(dsml.rs:199-200); in both casespublishis then invoked withliteral == None, so the retained text ships exactly once. -
End-before-begin ordering (dsml.rs:145-206).
ToolBeginis now pushed atToolNameEndguarded by!repeated;ToolEndatToolCallArgumentsEndalso!repeated;self.callsis incremented exactly once, after the end event, soEvent::ToolBegin{index}/ToolArguments{index}/ToolEnd{index}stay consistently indexed. A repeatedToolCallArgumentsEndaction falls through to_ => {}and cannot double-publish.ToolCallArgumentsEndtakes the call (self.call.take()), socheck_sizeat dsml.rs:218-220 cannot see a stale call. -
check_sizemoved before/after publication (dsml.rs:191-192 vs docs/api.md:571-575).check_sizeruns beforepublishon the text path, so the fragment that crosses the 1 MiB bound is never published and the call can never complete (self.callstaysSome, so a laterToolCallArgumentsEndre-checks). The documented "bound is enforced on the append that crosses it, after the call name and earlier fragments were published and are not retracted" is accurate.name.len().saturating_add(arguments.len())at dsml.rs:43 cannot overflow. -
drops_unfinished_call(cause) == cause != Termination::Eos(output.rs:479-481).Termination(helios/src/output.rs:51-58) has exactly five variants —Eos, OutputLimit, UserStop, Cancelled, ExecutionError. No variant is semantically an outlier that a!=test misclassifies: onlyEosmeans "the model finished naturally", so the predicate is total and non-degenerate (not always-true/always-false). Cross-checked against the parser's own Eos handling:DsmlOutput::finish(dsml.rs:376-395) errors onEosinside an announced call and clearsself.callforCancelled|ExecutionError, soAccumulator::finish's "incomplete emitted tool call" error (output.rs:163-168) remains reachable only on the genuinely-illegal path — the pre-PR contract is preserved exactly as claimed. -
Abandoned-index bookkeeping (output.rs:1735-1762, encode.rs:687-707).
finishonly marksabandonedwhenself.open.is_some()and the last block is aBlock::Tool;ToolBegin(output.rs:1811-1822) callsclosefirst and always pushes atblocks.len(), so an open tool block is always last →last == self.openandChange::End(last)matches;discard_abandonedthen pops exactly that block and itscallsentry, sohas_tools()(output.rs:1710-1712) afterwards reflects only completed calls and theRequired | Namedcheck at encode.rs:708-712 fails correctly (verified by the new test at tests.rs:4194-4231). Theabandoned |= truncated+incomplete_item = Nonereset at encode.rs:698-707 correctly scopes the marker to the discarded item so a later completed item is not mislabeledincomplete;self.incomplete_item = Some(*i)beforechange(change)is required becauseitem()reads it (encode.rs:340). -
Custom-tool truncation (encode.rs:470-517).
abandoned && customskipsserde_json::from_strandgrammar.validate, anditem(i, false)yieldsinput: ""withstatus: "incomplete"; the!abandonedguard suppressescustom_tool_call_input.delta/.done. Confirmed againstitem()(encode.rs:366-379). No partial input leaks. -
Strict-tool parking unchanged (encode.rs:571-631).
Event::ToolBeginfor a strict tool stillcontinues intopending_strict_calls[index]before anyResponseOutput/Accumulatormutation, and arguments are re-emitted only afterstrict_validators[..].validate(&arguments)succeeds — so no frame precedes schema acceptance. This matches the PR claim. -
Test-side consistency.
helios/tests/deepseek_output.rs:501-516and:581-595were correctly weakened from "no events published" to "noToolEndreported" (parsed.ended == 0), which is the only property that still holds now thatToolBegin/ToolArgumentspublish early; the rejection assertions at :514 still pin the error text.helios/tests/deepseek_requests.rs:684-693similarly concatenates fragments instead of requiring one whole-argument event. Both are correct adaptations, not weakened coverage of the new contract.
No numerical/median/comparator defects apply: the diff introduces no rate, median, EMA, eviction-priority or comparator logic; the only new arithmetic is self.blocks.len() - 1 (guarded by self.open.is_some(), so the vec is non-empty) and the existing saturating_add size checks. No integer overflow or 1e305-style NaN path exists in the changed code.
Not reported (out of scope per instructions): documentation wording, the PR-description's open questions to #364's author/reviewer, and CI-bookkeeping.
Full report · Notes Merge Risk: medium_high (100%): Medium or high merge risk (core runtime/scheduler/GPU/CUDA/VMM/RoCE/multi-rank/contracts/ABI, large multi-crate changes, or Blocker/Major findings) — route to Super Agent.
Re-review
Recommendation: Changes Requested
Commit 826a427 resolves every technical, protocol, documentation, and test-churn issue from Round 3: truncated Responses custom tool calls now close cleanly as incomplete with empty input instead of failing the request, abandoned function calls report status: "incomplete" across all non-EOS causes, docs/api.md accurately documents tool_choice: required/named failures and TAGGED_JSON-compatible tagged-parser behavior, and restoring Accumulator::finish(&self) shrank the diff from 15 files to 7. Direct verification found zero remaining code bugs or hot-path defects. The sole remaining blocker is the unresolved Round 3 governance gate (AGENTS.md:182-187, 201-207): the PR reverses #364's pre-publication 1 MiB / validation bound and main's non-EOS Err("incomplete emitted tool call") contract (along with their pinning tests and docs), and while the PR description now transparently asks @voipmonitor and @yatesdr to approve both changes, no maintainer decision is recorded on the PR yet. Once a maintainer signs off on both contract changes in the thread, no further code changes are required to merge.
Merge Risk
Level: Medium
- Unratified public-contract reversals:
DsmlOutput::applypublishesEvent::ToolBeginand argument fragments beforevalidate_argumentsand#364's 1 MiB bound (helios/src/output/dsml.rs:151-155, 191-205), anddrops_unfinished_callomits announced-but-unfinished calls onUserStop/Cancelled/ExecutionError(helios/src/server/output.rs:479-481, 1735-1748;helios/src/server/protocol/encode.rs:681-707), reversing two reviewedmaininvariants (docs/api.md:580-583, 600onmain,helios/tests/deepseek_output.rs:511onmain, anduser_stop_cannot_retract_an_already_emitted_partial_tool_call). - Prior protocol regressions and CI breakage resolved: Truncated Responses
customtool calls skip JSON/grammar validation and suppressresponse.custom_tool_call_input.{delta,done}(encode.rs:470-491, 511-514), abandoned Responses items reportstatus: "incomplete"across all non-EOS causes (encode.rs:687-707), Messages/Responses closing frames are emitted beforediscard_abandoned(), and thehelios/tests/integration suites pass on the updated contract. - No concurrency, memory, or hot-path regressions: All modified state is per-request (
helios/src/server/http.rs:358-400),Call::publishslices newly appended bytes within the 1 MiB buffer withpublished_argument_bytes <= literal_startpreserved acrossclose_literal,Encoder::applyfeeds one event at a time toAccumulator::apply(O(total bytes) total work), strict-tool parking (encode.rs:592-631) is untouched, andProtocol::Responsesis strictly single-choice (helios/src/server/protocol/decode.rs:835).
Walkthrough
- Incremental DSML publication (
helios/src/output/dsml.rs:38, 49-62, 151-155, 191-205): AnnouncesEvent::ToolBeginatToolNameEnd, tracksCall::published_argument_bytesand emitsEvent::ToolArgumentsfragments viaCall::publishafter eachToolCallArgumentsTextappend (keepingstring="false"literals unpublished untilclose_literalsettles them), and flushes trailing bytes plusEvent::ToolEndaftervalidate_arguments. - Non-EOS unfinished-call omission without
Accumulator::finishchurn (helios/src/server/output.rs:163-174, 479-481, 1707, 1735-1762): KeepsAccumulator::finish(&self)unchanged frommain, addsdiscard_unfinished_call(&mut self), addsdrops_unfinished_call(cause) -> cause != Termination::Eos, and exposesResponseOutput::is_abandoned(index)/discard_abandoned()so closing frames render before the truncated block is popped. - Abandoned-item and custom-tool handling in
Encoder(helios/src/server/protocol/encode.rs:470-491, 511-514, 681-707): Callsdiscard_unfinished_call()on Chat andResponseOutput::finish(cause)/discard_abandoned()on Messages/Responses, marks any abandoned Responses item asincompleteregardless of termination cause, skips JSON/grammar validation andcustom_tool_call_input.*frames for abandoned custom calls (emittinginput: ""), and clearsincomplete_itemafter discarding. - Tests & API docs (
helios/src/output/dsml.rs:750-1025,helios/src/server/protocol/tests.rs:56-87, 3844-4230,helios/tests/deepseek_{output,requests}.rs,docs/api.md:540-578): Adds folded truncation-matrix tests, truncated custom-tool and abandoned function-call tests,ToolChoice::Required | Namedfailure tests, UTF-8 split and literal-deferral tests, adaptsdeepseek_output.rs/deepseek_requests.rsfor streaming events, and updatesdocs/api.mdfor DSML streaming, custom-tool scoping, non-EOS omission,required/named failures, and post-publication 1 MiB enforcement.
Pre-merge Checks
- [PASS] Security / malicious screen: No unsafe code, external I/O, or instruction-hijacking patterns; 1 MiB parser (
helios/src/output/dsml.rs:22, 42-47, 234-236) and 8 MiB response (helios/src/server/output.rs:119-121, 1837-1839) bounds remain enforced. - [WARN] Charter & value fit: Directly serves the charter's coding-agent / heavy-tool-use vision with no per-model shared-layer branch and honest disclosure in the PR description, but reverses two reviewed
maininvariants (#364pre-publication bound and non-EOSincomplete emitted tool callerror) without the explicit maintainer sign-off required byAGENTS.md:182-187, 201-207. - [PASS] Related / duplicate / conflict check: No duplicate PR;
#670'sTAGGED_JSONsemantic mismatch indocs/api.md:540-547is fixed, and any rebase over#670is conflict-free;#364reversal is disclosed and tracked in Blocker #1. - [PASS] Tests & verification evidence: Full 15-target release
heliostest command (with1fbcc3c9baseline comparison explaining the 20 pre-existing environment failures),deepseek_output/deepseek_requests(15 passed each),flare(254 passed),flare-cli(245 passed), and live served parity probe are all reported on826a427.
Blockers
- Explicit maintainer sign-off still required for the two contract reversals and their accompanying test/doc rewrites (
AGENTS.md:182-187, 201-207;helios/src/output/dsml.rs:151-155, 191-205;helios/src/server/output.rs:479-481, 1269-1278, 1735-1748;helios/tests/deepseek_output.rs:515;docs/api.md:547-555, 574-576).- Verified behavior & impact: Both reversals remain active on
826a427and still have zero human maintainer comments or approvals in the PR thread:#364's pre-publication 1 MiB and key-validation guarantee (docs/api.md:600onmain, explicitly verified in@yatesdr's#364review and pinned byassert!(published.is_empty())athelios/tests/deepseek_output.rs:511onmain) is reversed soToolBeginand earlyToolArgumentsfragments publish beforevalidate_argumentsand before a subsequent append crosses 1 MiB, withdeepseek_output.rs:515weakened toassert_eq!(parsed.ended, 0, ...).main's non-EOSErr("incomplete emitted tool call")guarantee (helios/src/server/output.rs:165, 1728anduser_stop_cannot_retract_an_already_emitted_partial_tool_call) is replaced by silent omission viadrops_unfinished_call(cause) = cause != Termination::Eos(output.rs:479-481), renaming and inverting that regression test atoutput.rs:1269-1278.
- Under
AGENTS.md:182-187, 201-207, relaxing existing error/validation guarantees — including via accompanying test and doc updates — requires an explicit maintainer design decision on record before merging. - Fix: Obtain an explicit maintainer comment on this PR from
@voipmonitor/@yatesdr(or a repository maintainer) approving (a) post-publication validation and 1 MiB enforcement for streamed DSML calls and (b) non-EOS unfinished-call omission (vs restricting omission toOutputLimitor keeping the error). If approved as-is, no further code changes are needed.
- Verified behavior & impact: Both reversals remain active on
Should Fix
None.
Subtract / Simplify
- Have
Call::publishownself.check_size()?(helios/src/output/dsml.rs:53-62, 191-192, 201-203): ChangingCall::publishto returnResult<()>and callself.check_size()?before emitting makes the check-before-publish ordering structural in one place instead of repeating the two-line pair at:191-192and:201-203(keeping:218-220for non-publishing actions likeToolNameandLabelToolCallArguments). - Simplify the
custommatch inEncoder::changeandself.opencheck inResponseOutput::finish(helios/src/server/protocol/encode.rs:471-478;helios/src/server/output.rs:1737-1745):- In
encode.rs:471-478, matching&self.outputs[0].blocks[i]once avoids matchingBlock::Tooltwice to computecustomand then extractarguments. - In
output.rs:1737-1741,if drops_unfinished_call(cause) && let Some(last) = self.open && matches!(self.blocks[last], Block::Tool { ended: false, .. })usesself.opendirectly instead of re-derivingself.blocks.len() - 1viaself.blocks.last().
- In
- Disambiguate the remaining duplicate test name (
helios/src/output/dsml.rs:956vshelios/src/server/protocol/tests.rs:3960):a_truncated_second_call_keeps_the_completed_first_callstill exists verbatim in both files; prefixing the parser-layer test (e.g.,dsml_truncated_second_call_keeps_the_completed_first_call) keepscargo test <name>unambiguous.
Nits
docs/api.md:550-555line wrap & protocol clarity: Line 554 (...error event for streams. A client that received fragments...) is unwrapped relative to surrounding prose, and lines 550-551 ("The closing frame of such an item reports statusincomplete") describe Responses items specifically (Messagescontent_block_stopcarries nostatusfield and Chat has no per-call closing frame).- Custom-tool test cause matrix (
helios/src/server/protocol/tests.rs:4103):a_truncated_custom_call_closes_incomplete_without_failing_the_requesttestsOutputLimitandUserStop; addingTermination::CancelledandTermination::ExecutionErroraligns it withan_announced_call_is_omitted_when_the_response_truncates(:3846-3851).
Dropped on verification
- Code Correctness Finding 1 ("Major: O(N²) delta coalescing in
Accumulator::apply"): Dropped as a false positive. Verified athelios/src/server/output.rs:78thatlet mut deltas: Vec<Value> = Vec::new()is local to eachAccumulator::applycall (not persisted across tokens), and athelios/src/server/protocol/encode.rs:633-636that the sole production caller passesvec. The coalescing branch atoutput.rs:123-135never runs on the production Chat streaming path; total streaming work is O(total bytes). - Code Correctness Finding 2 ("Minor: Messages truncated call becomes a completed zero-argument
tool_useblock; omitcontent_block_stop"): Dropped as invalid. Suppressingcontent_block_stopaftercontent_block_startviolates Anthropic's SSE block-framing grammar and directly contradicts Round 1/2 Blocker #2; Anthropiccontent_block_stopcarries nostatusfield, andmessage_deltasignals truncation viastop_reason(max_tokens/stop_sequence/end_turnrather thantool_use,encode.rs:753-756, 833). - Subtraction Finding 1 ("cross-choice
incomplete_itembug acrossself.outputs+ replaceis_abandoned/discard_abandonedwithChange::End(usize, Outcome)"): Bug claim dropped as false positive, and refactor dropped to avoid moving-goalposts churn. Verified athelios/src/server/protocol/decode.rs:835(if protocol != Protocol::Completions && choices != 1) andencode.rs:348, 851thatProtocol::Responsesalways haschoices == 1(self.outputs.len() == 1), so no cross-choice interference is possible; furthermore,is_abandoned+discard_abandonedwas the exact API requested in Round 3 Subtract/Simplify #2. - Subtraction Finding 4 sub-claim ("
self.blocks.last()disagrees withself.openwhen an endedBlock::Toolis last andself.open == Some(text_block)"): Dropped as unreachable. Verified inResponseOutput::apply(helios/src/server/output.rs:1780-1864) that opening any block closes the previous block and pushes to the tail, andEvent::ToolEndimmediately setsself.open = None, soself.openis alwaysSome(self.blocks.len() - 1)when open. Kept only the cleanerself.openexpression under Subtract / Simplify #2. - Subtraction Finding 5 sub-claim ("
deepseek_output.rs:515should assert(parsed.began, parsed.ended) == (0, 0)"): Dropped as inconsistent with streaming. Under incremental DSML streaming,Event::ToolBeginis emitted atToolNameEndbefore duplicate/empty keys are parsed, soparsed.beganis necessarily1; the governance requirement for that contract change is tracked in Blocker #1. - Unobservable CI status and minor PR-description matrix wording (
GatesInfo notes): Dropped under the anti-pedantry rule.
Classify triage
Selected: triage:design-review
Threshold: 65%
Triage
- [✓]
triage:design-review: 97.4% -
triage:review: 2.6% -
none: 0.0% -
triage:partial: 0.0% -
triage:integration: 0.0% -
triage:investigate: 0.0% -
triage:validation: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0% Decision to Test: no (98%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.
Apply labels
Applied: +triage:design-review, -triage:review decide malicious: all_clear (100%): No malicious content found
explore
Author: peperunas (FIRST_TIME_CONTRIBUTOR; prior PR #519 closed unmerged; Discord: peperunas)
Motivation: DeepSeek tool calls used to arrive only once the whole argument object was parsed, so a multi-kilobyte write argument left the client's stream silent for the entire generation and an agent loop could not tell a working model from a hung one. The parser now announces the call when its name completes and streams argument bytes as the model writes them.
Scale: +869 / −59 lines in 7 files (head dfe38d4c; was +662/−72 in 13 files at first submission)
Proposal:
DsmlOutputemitsEvent::ToolBeginatToolNameEndand publishesEvent::ToolArgumentsfragments per argument-text action, withholdingstring="false"values untilclose_literalsettles them (helios/src/output/dsml.rs:38, 42-64, 147-158, 193, 195-205).- Non-EOS truncation now omits an announced-but-unfinished tool call instead of raising
incomplete emitted tool call, across all parsers and all three wire protocols (helios/src/server/output.rs:169-174, 477-481, 1735-1761;encode.rs:681-707). - Responses/Messages render the truncated item's closing frame first, report status
incomplete, and drop it afterwards (encode.rs:470-491, 687-702). - The 1 MiB bound and
validate_argumentsnow run after fragments are published, reversing #364's pre-publication ordering. docs/api.md:540-577is rewritten to describe the per-parser streaming guarantee, the omission rule and post-publication enforcement. Touches:helios/src/output/dsml.rs— streaming publication, size-check ordering.helios/src/server/output.rs/protocol/encode.rs— universal truncation semantics and item framing.docs/api.md— previously documented buffering now deleted and re-specified. Related items:- #364 Enforce DeepSeek tool call size and retain deeply nested values (merged): its pre-publication 1 MiB bound is reversed; author and reviewer have not replied.
- #102 Consult ignore_eos when classifying a finish reason at the output limit (merged): precedent for dropping an open envelope, OutputLimit only.
- #133 (closed): "changing stream semantics … is a maintainer policy decision", the basis for the remaining block.
- #679 (closed): endorsed
server_errorfor a rejected streamed call — opposite terminal. - #670 (merged): added
TAGGED_JSON; docs conflict resolved at826a427a, textual rebase only. Link: https://github.com/NVIDIA/hyperflare-inference/pull/685 Autobot comments: The new event is the fifth Autobot Review (2026-12-05 12:06, on826a427) which retires every technical blocker and leaves only a governance gate; the head then moved todfe38d4c, which is itself unreviewed. The PR label silently flipped fromtriage:reviewtotriage:design-review— this repo's marker for "a design decision, not a defect fix" — with no comment. The new docs sentence overstates reach: it says every non-EOS termination omits the call, but a generationCancelled/ExecutionErrortakes the failure path, so the ExecutionError test row is test-only. Still open: the integration assertion athelios/tests/deepseek_output.rs:514-515was weakened to repair CI (main:511assertedpublished.is_empty()), no CI run exists on any hash, and zero human comments or reviews exist despite the author asking both area owners twice more.
Classify intake
Selected: triage:design-review, performance, enhancement, area:api, model:deepseek-v4, model:deepseek-v4.1
Threshold: 65%
Triage
- [✓]
triage:design-review: 99.4% -
triage:review: 0.5% -
none: 0.0% -
triage:investigate: 0.0% -
triage:verify-for-closure: 0.0% -
triage:validation: 0.0% -
triage:integration: 0.0% -
triage:partial: 0.0% -
triage:superseded: 0.0%
Priority
-
none: 75.7% -
priority:P2: 21.7% -
priority:P1: 2.6%
Type
- [✓]
performance: 81.8% - [✓]
enhancement: 67.9% -
bug: 59.3% -
community: 40.7% -
duplicate: 26.9% -
documentation: 4.7%
Area
- [✓]
area:api: 99.6% -
area:memory: 5.3% -
area:preparation: 1.6% -
area:engram: 1.4% -
area:selene: 1.2% -
area:caching: 0.5% -
area:packaging: 0.3% -
area:kernels: 0.2% -
area:rocenante: 0.2% -
area:orbit: 0.1% -
area:scheduling: 0.0%
Model
- [✓]
model:deepseek-v4.1: 94.0% - [✓]
model:deepseek-v4: 88.1% -
model:qwen3.8-27b: 1.4% -
model:qwen3.8-flash-next: 1.4% -
model:gemma4: 1.2% -
model:inkling-small: 0.9% -
model:glm-5.3: 0.5% -
model:kimi-k3.1: 0.5% -
model:muse-glimmer: 0.3% -
model:nemotron-3.5-bolt: 0.1% -
model:mimo-v2.6: 0.0%
Apply Labels (Intake)
No label changes
Gates and contracts
Contracts, Charter & Verification Gates audit — PR #685 @ dfe38d4c
Audit scope: the four hard gates only. Read-only static reading at head dfe38d4c05af3005a7d55d12e70003b29789f932 (pr_files, pr_diff, read_file, read_item(364), pr_comments, main refs). Nothing was executed. Prior rounds' verification evidence (## Case File History, five Autobot reviews, pr_comments) was checked before judging Gate 3.
Head shape: 7 files, +869/−59 — docs/api.md (+30/−12), helios/src/output/dsml.rs (+304/−14), helios/src/server/output.rs (+46/−13), helios/src/server/protocol/encode.rs (+35/−12), helios/src/server/protocol/tests.rs (+428/−0), helios/tests/deepseek_output.rs (+15/−6), helios/tests/deepseek_requests.rs (+11/−2).
Verdict: one Gate 1 blocker (authority prong), in one family with two parts. Gates 2, 3 and 4 pass. No vendored-file, dependency-pin, mandatory-verification or material-scope gate is violated.
Gate 1 — Core-format / wire / public-contract boundaries
Mechanical prongs: PASS
- No new proto, core-format enum, captured-graph operation family, wire kind,
Event/Terminationvariant, config switch or environment variable.Event::{ToolBegin,ToolArguments,ToolEnd}already exist onmain; the PR re-times their emission (helios/src/output/dsml.rs:147-158, 175-206) and adds no variant.docs/core-format-design.md,docs/scheduling-theory.md(not opened),docs/scheduling-runtime-design.mdare untouched and unrelated (theirstreamhits are cache/preparation payload streams and scheduler delivery pricing, not the parser). - The one
docs/core-design.mdinvariant in this area is preserved, not contradicted:docs/core-design.md:1695-1697— "The output encoder holds the call until it has validated the complete arguments; a truncated strict call does not publish partial arguments." Strict tools still park inpending_strict_callsbefore anyResponseOutput/Accumulatormutation and re-emit only afterstrict_validators[..].validate(&arguments)(helios/src/server/protocol/encode.rs:592-596, 607-628).docs/api.md:758-762(strict buffering, output-limit/user-stop omission, EOS error, required/named failure) likewise still matches the code. - No captured-graph operation family is introduced, so the
docs/design-review.md:22-26owner-approval requirement is not engaged.
BLOCKER 1 — two previously attested invariants are reversed, and the test that pinned one was weakened, before the maintainer decision the PR itself requests exists (AGENTS.md:182-187, 201-207; docs/design-review.md:135-146)
Both reversals are real, both are disclosed in the description, and both were asked about in the thread — but neither has an answer, and pr_comments shows zero human comments or reviews in the entire thread (three Autobot reviews, plus the author's pings at 2026-12-05 12:10 and 12:22 asking @voipmonitor/@yatesdr to accept them).
- #364's pre-publication 1 MiB / key-validation bound.
mainstates the guarantee normatively:docs/api.md:600— "Helios rejects a larger call before publishing it." Its author@voipmonitorshipped it for exactly that reason (read_item(364)body: "checks the UTF-8 byte count of the name plus the complete argument object before emitting the first tool event"), and its reviewer@yatesdrattested the property on the record (read_item(364), review 2026-11-18 23:54: "The size check now runs after the final value is quoted and the closing text appended, before any event is published").- At head the order is inverted:
Event::ToolBeginis pushed atToolNameEnd(dsml.rs:147-158) and fragments are published per argument-text action (dsml.rs:175-193), sovalidate_arguments(dsml.rs:202) and the 1 MiBcheck_sizeinsidepublish(dsml.rs:53-54→:42-47) run after publication. This is documented honestly atdocs/api.md:573-577("enforced on the append that crosses it, after the call name and earlier argument fragments were published and are not retracted").
main's non-EOSErr("incomplete emitted tool call").Accumulator::finishstill errors (helios/src/server/output.rs:163-168) andResponseOutput::closestill errors at Eos (output.rs:1728), but the newdrops_unfinished_call(cause) = cause != Termination::Eos(output.rs:477-481) is applied fromEncoder::finishon Chat (encode.rs:681-686) and fromResponseOutput::finish(output.rs:1735-1748) for Messages/Responses, soUserStop/Cancelled/ExecutionErrornow succeed with the termination's finish reason while the announced call is omitted.docs/api.md:580-583onmainscoped omission to the output limit ("Truncated tool envelopes are omitted and the response reports its output limit"); head generalises it to every non-EOS cause across all parsers and all three wire protocols (docs/api.md:546-550).
- A pinning assertion was deleted to make the suite green.
mainhelios/tests/deepseek_output.rs:511assertsassert!(published.is_empty())after a duplicate/empty-parameter rejection — precisely the #364 property. Head replaces it withassert_eq!(parsed.ended, 0, "a rejected call reported an end")(:515) and drops theis_empty()push assertions inparse_literal_parameters(main:576, 581→ head:579-595, routing events intoParsedinstead). That is the case AGENTS.md names verbatim.
AGENTS.md:201-207 is explicit that this is a prior decision, not a review-time one: "Resolve conflicts through an explicit maintainer decision on the design before implementing a change to that invariant … Apply these criteria to documentation and test changes that would weaken the rules as well as code." docs/design-review.md:143-146 adds: "Reject changes that bypass validation, conceal unsupported behavior, weaken … contracts … Do not make a violating contribution acceptable by weakening its governing rule." Updating the contradicted doc (docs/api.md:540-577) is required work but is not authorization; honest disclosure in the description is likewise not the recorded decision.
Mitigating context, weighed but not a waiver: omission at OutputLimit was already accepted in #102, and docs/api.md:552-554 correctly discloses the required/named exception implemented at encode.rs:708-712 (pinned by helios/src/server/protocol/tests.rs:4200-4235). That narrows the delta to UserStop/Cancelled/ExecutionError — and Cancelled is genuinely reachable in production (helios/src/server/runtime.rs:326 → finish_cancelled, plus the tool-limit remap at encode.rs:673 and http.rs:527) — but the delta is still unratified.
What closes it: a maintainer comment on this PR (@voipmonitor / @yatesdr, or any repository maintainer) approving (a) post-publication validation and post-publication 1 MiB enforcement for streamed DSML calls and (b) non-EOS omission of an announced-but-unfinished call for all parsers and protocols — including the accompanying doc rewrite and the weakened deepseek_output.rs:515 assertion. If the answer is no to either, the corresponding code must change rather than the rule. triage:design-review (applied after the last review) is consistent with triage classifying this as exactly that decision.
Gate 2 — Vendored upstream dependencies & cross-PR conflicts: PASS
- No vendored upstream file is touched:
pr_filescontains nohelios/native/*(or anynative/) path; the RoCE proxy and other vendored C are absent. - No dependency change:
helios/Cargo.toml:35-37pinsdeepseek-recipe/-core/-encodingto the samerev = "70be62f30c64400229fcdb233a7f19a03a5e8ed6"onmainand at head, and noCargo.toml/Cargo.lockappears in the diff. Thedeepseek-recipeaction stream the PR re-times is consumed from that unchanged pin. - No dependence on an unmerged external recipe/PR.
- Cross-PR conflicts are textual only: #670 (merged,
TAGGED_JSON) landed after the branch point and its semantic staleness is repaired at head —docs/api.md:545-546no longer carries the false "because they build its arguments from parameter syntax …" clause, andhelios/src/output/tagged_json.rsemits noToolBegin/ToolArguments(no matches), so "The tagged tool parsers publish a call only when its envelope is complete" is accurate. #461 (open) edits thetool_choiceparagraph atdocs/api.md:648-687, a different range from #685's:540-577; whichever lands second needs a small rebase. Info only.
Gate 3 — Mandatory verification evidence & failing tests: PASS
- Layer 3 not triggered. No GPU/CUDA/VMM execution path, scheduler, cache, worker lifecycle, admission/fence/generation/speculation, or rank coordination is touched; the diff is confined to a model output parser and per-request HTTP encoder/accumulator state.
verification/helios-lifecycle/README.md:137states "HTTP encoder state is outside the TLA+ projection," anddocs/design-review.md:210-215scopescheck.pyto admission, fences, generations, cancellation, speculation accounting, cache compaction, snapshot aliases, response buffering or ownership, offload aggregation, readiness and rank coordination — the changed types (DsmlOutput,Accumulator,ResponseOutput,Encoder) are the HTTP encoder layer the README excludes.Decoder::drop → abort(Cancelled)(output.rs:471-475) is unchanged by this diff. No Kani surface (completion-vector validation, prepared completion contracts, extent arithmetic, sequential validators) is touched. No mutation-guard (check.py --mutations) obligation, since no safety guard is added. - No performance claim requiring an A/B served benchmark. The claim is frame-arrival timeliness (2 frames → 566 for a 2.2 KB
writeargument), not a throughput/speedup claim (docs/design-review.md:106-115governs performance gains). No core-format change, so no live export/serve or legacy-core replay is required. - Layer 1 evidence is present and honestly reported, so nothing here is flagged. The body gives the exact command (
cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --no-fail-fast), 1848 passed / 20 failed / 84 ignored on this head, and the same command at the branch point1fbcc3c9giving 1776 passed / 17 failed plus the same threemessage_boundariesfailures — i.e. all twenty failures predate the PR. Both failure families are environment-attributed and the CI workflow supplies exactly what they need:.github/workflows/native-serving.yml:62(not opened) (prlimit --memlock=67108864) covers the eleven engramRLIMIT_MEMLOCKfailures and:59, :67(FLARE_TEST_TEMPLATE_DIR) covers the nine chat-template failures.deepseek_output/deepseek_requestsare reported at 15 passed each;flare254 andflare-cli245 passed. Per the calibration rule I do not flag the absence of an observable CI check-run. - No reported failing test or failing check remains about the diff itself. The four
helios/tests/failures of earlier rounds are adapted at head (deepseek_output.rs:499-516, 576-595;deepseek_requests.rs:683-693now concatenates fragments instead of parsing each one) — their adequacy is a Gate 1 question (the:515weakening), not a Gate 3 evidence gap.
Gate 4 — Material scope / claim contradictions: PASS, two Info notes
No unrelated standalone tooling, no bundled refactor, no scope expansion; the +869 lines are dominated by tests (protocol/tests.rs +428, dsml.rs tests +303) that all target the changed behavior. No claimed test or benchmark is absent from the diff.
- Info — coverage wording overstates the custom-call matrix. The body says the tests drive "a truncated custom call and a truncated function call on all three wire protocols and every termination cause." Custom tools exist only on Responses (
helios/src/server/protocol/decode.rs:393,:420-422), soa_truncated_custom_call_closes_incomplete_without_failing_the_request(protocol/tests.rs:4102-4150) is Responses-only (it does now cover all four causes). The function-call matrix is genuinely 3 protocols × 4 causes (:3844-3957). The tests exist; only the sentence is imprecise. Also, "one table per property" describes five hand-written cause literals (dsml.rs:925-931,:958-964,protocol/tests.rs:3846-3851, 3962-3966, 4103-4108), anda_truncated_second_call_keeps_the_completed_first_callomitsExecutionError(:3962-3966). - Info —
docs/api.md:546-550over-reaches slightly on reachability. "Omitted … for every termination other than natural end-of-sequence" is true for OutputLimit, UserStop and tool-limit-remapped Cancelled, which reachEncoder::finish(http.rs:527, 534-540;encode.rs:673). A generation ExecutionError takes the separate failure path (http.rs:562→575-579Delivery::Failed, buffered rejection at:639), so theExecutionErrorrow of the matrix is reachable only by injecting events as the tests do. What ships matches the prose for every production cause; the sentence is one step broader than the code path.
Deliverable verdict
One hard gate violated: Gate 1, authority prong — AGENTS.md:182-187 and :201-207 (weakened guarantee, weakened pinning test, invariant changed before the required maintainer decision), with docs/design-review.md:143-146. Gates 2, 3 and 4: no blockers.
If the maintainer decision lands in the thread accepting both reversals, no further code change is needed for this lens; if it lands against either, the corresponding code, doc sentence and test assertion must revert rather than the rule.
Subtraction and simplicity
Subtraction & Simplicity audit — PR #685 (dfe38d4)
Verdict: the production diff is lean, and the streaming core is genuinely minimal. Call::publish (helios/src/output/dsml.rs:49-64) is 15 lines and does the whole feature; Event::ToolBegin at ToolNameEnd is 6 added lines (dsml.rs:153-157); the DSML ToolCallArgumentsEnd arm shrank on net (dsml.rs:195-205). No flag, config knob, trait, per-model branch or speculative abstraction is added anywhere in the diff. Everything worth flagging sits in the truncation bookkeeping split across two modules and in test scaffolding — which is where +428 (protocol/tests.rs) and +304 (output/dsml.rs) came from.
Citations are at head dfe38d4; nothing was executed, all statements are static reading of the diff and files.
1. Encoder adds a second, mark-then-clear copy of "this item is abandoned" — HIGH
helios/src/server/protocol/encode.rs:687-707:
let mut abandoned = false;
for change in self.outputs[index].finish(cause)? {
if self.protocol == Protocol::Responses
&& let Change::End(i) = &change
{
let truncated = self.outputs[index].is_abandoned(*i);
if truncated || cause == Termination::OutputLimit {
self.incomplete_item = Some(*i);
}
abandoned |= truncated;
}
frames.extend(self.change(change)?);
}
self.outputs[index].discard_abandoned();
// The buffered response is rendered after this returns, so the marking
// outlives the change that set it unless the item is gone.
if abandoned {
self.incomplete_item = None;
}
Two facts are tracked for the same block: incomplete_item (read later by item() at encode.rs:340-341 when the buffered body is rendered) and the local abandoned, which exists only to undo the first. The undo only exists because one field serves two renders, and abandoned |= plus the post-loop unset is treating a symptom of that: the restore is skipped for every end in the call, not just the last. change() already receives the index, so the abandoned flag can be passed down into item(i, complete) / change(change, abandoned) and incomplete_item left carrying only the OutputLimit case it carried before this PR (which is all encode.rs:695's || adds). That deletes abandoned, truncated, the trailing if abandoned and its three-line comment: ~8 lines and one piece of hidden state.
2. ResponseOutput.abandoned + is_abandoned + discard_abandoned is a channel where a return value would do — MEDIUM/HIGH
helios/src/server/output.rs:1735-1761:
pub fn finish(&mut self, cause: Termination) -> Result<Vec<Change>> {
let mut changes = vec![];
if drops_unfinished_call(cause)
&& let Some(index) = self.open
&& matches!(self.blocks[index], Block::Tool { ended: false, .. })
{
changes.push(Change::End(index));
self.abandoned = Some(index);
self.open = None;
}
self.close(&mut changes)?;
Ok(changes)
}
pub fn is_abandoned(&self, index: usize) -> bool { self.abandoned == Some(index) }
pub fn discard_abandoned(&mut self) {
if self.abandoned.take().is_some() {
self.blocks.pop();
self.calls.pop();
}
}
The index is already fully known inside finish; storing it in a field so the caller can re-read it through is_abandoned (called twice: encode.rs:471 and encode.rs:694) makes a three-method protocol for one value. finish returning (Vec<Change>, Option<usize>) and the caller holding it in a local across the loop removes abandoned, is_abandoned, and discard_abandoned's field entirely. Two concrete defects of the same design: (a) discard_abandoned discards the index it just took and pops positionally — correct only because an abandoned block is always last; let Some(index) = self.abandoned.take() + self.blocks.remove(index) / self.calls.remove(...) is the same line count and states the invariant instead of depending on it; (b) self.open = None; here duplicates the identical line close() executes three lines later (output.rs:1726-1731).
3. The 1 MiB check now runs twice per published fragment — MEDIUM
helios/src/output/dsml.rs:53-54:
fn publish(&mut self, index: usize, events: &mut Vec<Event>) -> Result<()> {
self.check_size()?;
and helios/src/output/dsml.rs:218-220, at the end of every action in apply:
if let Some(call) = &self.call {
call.check_size()?;
}
publish is reached only from the ToolCallArgumentsText arm (dsml.rs:193), whose every path has already run the loop-level check on the previous action and will run it again on this one — so the same inequality is evaluated three times per fragment. Round 4 deliberately moved the check into publish; the loop-level call could then be narrowed to actions that do not publish, or dropped for the text action. check_size is cheap, so this is a legibility item, not perf — but as written a reader has to work out which of two identical guards produces which error ordering (dsml.rs:202 validate precedes :203 publish).
4. custom tracked by a mutable flag, then re-derived anyway — LOW
encode.rs:472-476:
let mut custom = false;
if let Block::Tool { name, arguments, .. } = &self.outputs[0].blocks[i]
&& self.tool(name).is_some_and(|tool| tool.custom)
{
custom = true;
is one expression as matches!: matches!(self.outputs[0].blocks[i], Block::Tool { name, .. } if self.tool(name).is_some_and(|t| t.custom)), leaving arguments bound only inside the if !abandoned body. Five lines to one, no let mut.
5. Test scaffolding duplicates the helper it sits beside — LOW/MEDIUM
helios/src/server/protocol/tests.rs:56-74 re-lists all ten Encoder::new arguments verbatim from encoder_with_parallel (tests.rs:36-53), differing only in tools[0].custom = true; calling encoder_with_parallel(Protocol::Responses, tool_choice, true) and setting encoder.tools[0].custom = true removes ~14 duplicated lines. Same shape in dsml.rs: streaming_tests::config() (dsml.rs:757-763) and rejection_tests::parser() (dsml.rs:987-995) are the same OutputConfig differing only in start, and the two adjacent mods re-import the same five names (dsml.rs:751-755 vs :988-991); one config(start: OutputStart) in a shared #[cfg(test)] mod removes the pair.
6. Trailing blank line at EOF — NIT
helios/tests/deepseek_output.rs:834 — the diff's final hunk adds an empty line after the closing brace, leaving the file ending }\n\n.
Checked and already lean (do not re-raise)
drops_unfinished_call(cause) -> cause != Termination::Eos(output.rs:479-481) is a named predicate, not a boolean threaded through three signatures;Accumulator::finishkeepsmain's&selfshape (output.rs:163-168), so the earlierfinish(cause)churn is genuinely gone.Call::publish's single early return (dsml.rs:55) collapses "literal still open" and "nothing new" correctly;published_argument_bytesis oneusize, not a parallel fragment vector.- Strict tools reuse the existing
strictfield +pending_strict_calls(encode.rs:674-678) with no new flag. Changegained no variant;is_abandoned/discard_abandonedhave exactly the call sites listed above — no dead code, no unreachable branch, no new CLI/config surface (pr_files: 3 source files + 3 docs/tests).BUFFER_LIMIT(dsml.rs:22) is reused by both the call bound and the pending-buffer bound (dsml.rs:234-236) rather than gaining a second constant.
Bottom line: nothing blocks on simplicity grounds. Items 1 and 2 are the ones I would insist on — together they are ~20 lines of two-way bookkeeping (incomplete_item ↔ abandoned) that a single value passed down the change() path replaces, and discard_abandoned currently pops positionally while holding the index that says where to pop.