#1 [high] A (high): finish(cause) parameter sweep — collapse to finish() + explicit drop at the one real call site
helios/src/server/output.rs:476-480
/// Whether a termination cause drops a tool call that was announced but never
/// completed, instead of reporting it as an incomplete call.
pub(crate) fn drops_unfinished_call(cause: Termination) -> bool {
cause != Termination::Eos
}
Two uses only: output.rs:164 and output.rs:1731. The new parameter cause: Termination on Accumulator::finish (output.rs:163) and ResponseOutput::finish (output.rs:1730) is an implicit mode flag: every caller in the repo passes Termination::Eos except Encoder::finish (encode.rs:675, :677). Mechanical churn sites (all finish() -> finish(Termination::Eos)):
output.rs:721,723,1346,1379,1431,1432,1648,1676; phase_tests.rs:765,973; argument_tags.rs:209/287/334/435/490; chatml.rs:415,647,830,1094; gemma_call.rs:265; minimax_xml.rs:; xtml.rs:461,505; pipeline.rs:342,489,577,682,735; protobuf.rs:1157. That is 8 files touched for one call site's decision.
Simplification: keep fn finish(&mut self) -> Result<()> (Accumulator) and fn finish(&mut self) -> Result<Vec<Change>> (ResponseOutput) unchanged, and add one explicit method, e.g. pub(crate) fn drop_unfinished(&mut self) on each, called from Encoder::finish before finish() when cause != Termination::Eos:
- deletes
drops_unfinished_callentirely, - deletes the ~30 mechanical
finish(Termination::Eos)edits across 8 files (argument_tags.rs, chatml.rs, gemma_call.rs, minimax_xml.rs, xtml.rs, pipeline.rs, protobuf.rs, phase_tests.rs, plus output.rs tests), - makes the drop visible at its single decision point (encode.rs:666-677) instead of threaded through an accumulator API that in production only ever sees one non-Eos value.
Note: on main Accumulator::finish/ResponseOutput::finish are also called from the Chat path (encode.rs:675) and unconditionally (encode.rs:677); a drop_unfinished on both preserves today's exact behaviour, and strict-tool parking (encode.rs:567-621) is unaffected.
#2 [high] B (high): duplicated truncation tests — same two test names in dsml.rs and protocol/tests.rs
+285 lines in helios/src/output/dsml.rs (mods streaming_tests 749-985 and rejection_tests 987-1032) and +266 lines in helios/src/server/protocol/tests.rs (3808-4074).
Duplicate test names across the two files:
fn a_truncated_second_call_keeps_the_completed_first_call()— dsml.rs:940 and protocol/tests.rs (hunk@@ -3805second block, ~3893). Same scenario (completed call + truncated second), different layer: dsml one drives Accumulator, protocol one drives Encoder over synthetic events.fn a_header_only_call_is_omitted_when_the_response_truncates()— dsml.rs:963 and protocol/tests.rs ~3965.
The protocol copies use hand-built Event:: vectors (no parser), so the DSML-side copies are only adding "the parser produced these events", which is already covered by a_call_opens_and_publishes_arguments_before_its_envelope_closes (dsml.rs:793) and a_truncated_call_keeps_its_published_fragments_and_omits_the_stored_call (dsml.rs:917). Recommend keeping one per name (the protocol-level one, since the buffered body + finish_reason is the user-visible contract) and deleting the dsml.rs duplicate; ~90 lines.
Also removable: rejection_tests::end_of_sequence_inside_an_announced_call_is_an_error (dsml.rs:1002-1011)
#[test]
fn end_of_sequence_inside_an_announced_call_is_an_error() {
let mut parser = parser();
let events = parser.push(Input::Text(
"<|DSML|tool_calls><|DSML|invoke name=\"write\"><|DSML|parameter name=\"q\" string=\"true\">par",
)).unwrap();
assert!(events.iter().any(|event| matches!(event, Event::ToolBegin { .. })));
assert!(events.iter().any(|event| matches!(event, Event::ToolArguments { .. })));
assert!(parser.finish(Termination::Eos).is_err());
}
The Eos-is-an-error half is already asserted by the existing integration test incomplete_calls_do_not_finish_on_eos_and_can_be_cancelled_or_truncated (helios/tests/deepseek_output.rs:387-421, which loops Eos -> is_err and the four other causes -> Ok), and the two event assertions are asserted by the streaming tests above. Whole rejection_tests module (~45 lines incl. its own parser() fixture duplicating streaming_tests::config()) can go apart from the publish-before-reject assertion.
#5 [high] Research summary
Subtraction/simplicity review of #685 complete; findings saved as scratchpad notes 1–4.
The substantive streaming change is genuinely lean: Call::publish is 10 lines, guarded by one predicate (literal.is_some()), and needs only one new field (published_argument_bytes). DsmlOutput loses 9 lines at ToolCallArgumentsEnd. Most of the +662 arrives as tests and the finish(cause) parameter sweep, and that sweep is where the removability is.
Four suggestions, all with exact quotes and concrete replacements:
- High —
Accumulator::finish(cause)/ResponseOutput::finish(cause)plus thedrops_unfinished_call(cause)helper (server/output.rs:163, 476-480, 1730) encode a single boolean, and ~20 of ~21 call sites passTermination::Eos. Replace with an explicitdrop_unfinished()called once fromEncoder::finish: deletes the helper, the parameter, and ~30 mechanical edits across 8 files (argument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs(not opened),xtml.rs,pipeline.rs,protobuf.rs,phase_tests.rs, plus output.rs's own tests). - High — two new tests are duplicated under identical names in both
output/dsml.rsandserver/protocol/tests.rs(a_truncated_second_call_keeps_the_completed_first_call,a_header_only_call_is_omitted_when_the_response_truncates), and the wholerejection_testsmodule (dsml.rs:987-1032) re-asserts whathelios/tests/deepseek_output.rs:387-421and the streaming tests already cover, with its own duplicateparser()fixture. ≈135 removable lines. - Medium — the PR adds
call.check_size()?atdsml.rs:191while the pre-existing post-matchcheck_sizeatdsml.rs:218-220still runs on the same state; drop one, and note that the newdocs/api.md:570-572sentence documents the 218 behaviour while the new code makes 191 load-bearing first. - Medium —
docs/api.md:543-551adds two sentences that are not this PR's subject: a tagged-parser justification that is already stale on main (tagged_json.rs(not opened) coerces nothing) and an editorial line about clients seeing fragments. Replace with the one-clause main sentence, inverted.
No architectural/convention violation of the "no flags, no speculative abstraction" kind: no new config knob, no fallback layer, no dead code left behind. The finish(cause) sweep is the one instance of a flag-like parameter, and it is fixable as described. The deletion of Err("incomplete emitted tool call") for non-Eos causes is a Correctness/Contracts matter already recorded in the case file, not restated here; if that behaviour is reversed, suggestion 1 evaporates entirely, which is a further argument for not threading the cause through the accumulator API.
#6 [high] E (high): overall verdict, inventory, and citation caveats for the subtraction lens
VERDICT: the substantive streaming change is lean and idiomatic. Do not dress this up as a style problem. Removability is concentrated in two places — the finish(cause) parameter sweep (note #1) and duplicated/overlapping new tests (note #2) — plus two small ones (notes #3, #4).
What is lean and should be said so plainly:
Call::publish(helios/src/output/dsml.rs:49-62) is 10 lines plus doc, one guard (literal.is_some()), one new fieldpublished_argument_bytes(dsml.rs:38), and reuses the existingcheck_sizebound. No new flag, config knob, trait, wrapper, fallback layer, or dead code.ToolCallArgumentsEnd(dsml.rs:194-206) is a net simplification of the old 3-event extend (main dsml.rs hunk removing 9 lines).- No speculative generality:
Event::ToolArgumentsalready existed with the right shape;Encoder/Accumulator/ResponseOutputneeded no new event variant. - No AGENTS.md "unsupported abstraction / churn / flags bypassing boundaries" violation. The
finish(cause)parameter is the closest thing to a flag and is addressed in note #1; it is structural, not a rule violation. - Strict-tool parking (encode.rs:567-621) untouched and still buffers, as documented.
INVENTORY of the 13 changed files for the report:
- Substantive:
helios/src/output/dsml.rs(+315/−18; ~30 of those lines are production code, ~285 are tests),helios/src/server/output.rs(+33/−19; 12 production lines incl.drops_unfinished_call),helios/src/server/protocol/encode.rs(+2/−2, the sweep),docs/api.md(+25/−12). - Tests only:
helios/src/server/protocol/tests.rs(+266/−0), and 8 files touched solely by thefinish(Termination::Eos)mechanical edit:helios/src/output/argument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs,xtml.rs,pipeline.rs,helios/src/runtime_core/protobuf.rs,helios/src/server/runtime/phase_tests.rs. (Theminimax_xml.rsdiff was not fetched — its +1/−1 matches the pattern of the other seven.)
CITATION CAVEATS to state honestly in the report:
- Line numbers for the two duplicated tests in
helios/src/server/protocol/tests.rsare APPROXIMATE (~3893, ~3965, within the added hunk@@ -3805,3 +3805,269 @@, added lines 3808-4074). The dossier pins 3810, 3894, 4004 for the block starts. Identify the tests by name, not by line, in the final text, or mark the numbers approximate. - Note #2's claim that the dsml-side copies are redundant depends on
a_call_opens_and_publishes_arguments_before_its_envelope_closes(dsml.rs:793-842) anda_truncated_call_keeps_its_published_fragments_and_omits_the_stored_call(dsml.rs:917-937) already covering the event-level facts; that is verified by reading them. - Note #2's overlap claim is verified against
helios/tests/deepseek_output.rs:387-421(incomplete_calls_do_not_finish_on_eos_and_can_be_cancelled_or_truncated), which loopsTermination::Eos->is_err()and OutputLimit/UserStop/Cancelled/ExecutionError ->unwrap().
INTERACTION with the correctness lens (do not duplicate it, but the report should note the dependency): if the reviewer decides the non-Eos drop is wrong and the Err("incomplete emitted tool call") branch must be restored for non-Eos causes, suggestion #1 becomes trivially true — the accumulator API returns to finish() with no argument at all. Recommend the simplification in those terms: it is strictly better under either correctness outcome.
#3 [medium] C (medium): redundant check_size inside the argument-text action
helios/src/output/dsml.rs:188-192 (added)
}
call.check_size()?;
call.publish(self.calls, events);
}
and the pre-existing, unchanged lines dsml.rs:218-220
if let Some(call) = &self.call {
call.check_size()?;
}
Both run for every ToolCallArgumentsText action; the second re-checks state the first just validated (nothing appends between them except publish, which only reads). One of the two should go.
Which to remove: keeping only 218-220 is the smaller diff and preserves all existing guarantee tests (helios/tests/deepseek_output.rs:530-566, 568-593 rely on the post-match check), at the cost that the fragment which crosses 1 MiB is published before the error. Keeping only 191 means the crossing fragment is never published — but then note that docs/api.md:570-572's new wording ("The bound is enforced on the append that crosses it, after the call name and earlier argument fragments were published") describes the 218-only behaviour, so code and doc currently disagree about which of the two checks is load-bearing. Pick one and align the sentence.
Not a validation-removal concern: the bound is still enforced on every append either way (AGENTS.md:182-187 satisfied); only the duplicate disappears.
#4 [medium] D (medium): docs paragraph overreach — trim out-of-scope/stale sentences
docs/api.md:543-551 (added)
byte for byte. 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. An announced call cut off before completion is omitted from a
buffered response for every termination other than natural end-of-sequence, and
the response reports that termination's finish reason; only an output-limit
termination reports the output limit. A client that received fragments of such a
call has already seen a call that cannot complete.
Two removals:
- The tagged-parser justification (543-547) is not this PR's change (tagged parsers are untouched) and is already stale:
TAGGED_JSONon main parses the model's own{"name":…,"arguments":…}object and re-serializes it (helios/src/output/tagged_json.rs:14-57) rather than coercing to declared schemas. The pre-existing main sentence it derives from was "The model parsers buffer tool envelopes until they are complete, so argument events do not imply incremental generation of an unfinished call." (docs/api.md:540-543 on main) — one clause, correct for every parser. Replace 543-547 with that clause, inverted for DSML only: "The tagged tool parsers publish a call only when its envelope is complete, so their argument events do not imply incremental generation." A client that received fragments of such a call has already seen a call that cannot complete.(550-551) is commentary, not contract, and describes precisely the unresolved framing gap (nocontent_block_stop/response.output_item.donefor the dropped call). Delete.
Keeps the delta honest and shrinks the docs hunk from ~12 new lines to ~4.