#1 [high] Blocking: ~700 lines of new tests re-prove behaviour existing tests already cover
Change size: 9 files, +1423/−70. Production code is ~120 lines (tagged.rs +66/−28, argument_tags +280 incl. tests, chatml +206, gemma +130, minimax +167, pipeline +108 — of these only ~25/25/12/25/6 lines are non-test). ~1150 added lines are tests, ~365 of them in one new test.
Duplication with tests already on main:
- helios/src/server/protocol/tests.rs:2350-2665 (new, 348 lines)
unclosed_tagged_tool_calls_at_eos_match_protocol_and_control_semanticsloops 5 dialects × 3 protocols and re-asserts:- undeclared-call handling + streamed-vs-buffered argument equality: already
auto_tool_choice_returns_unknown_calls_across_parsers_and_protocols(tests.rs:407-611, same 5 parser kinds incl. GLM/Qwen, same per-protocol frame extraction loop). parallel_tool_calls: falsekeeps call 1, discards call 2, setstool_limit_reached: alreadydisabled_parallel_calls_stop_before_the_second_call_is_emitted(tests.rs:723-765).- Required/Named accepting a completed call and rejecting undeclared: already
required_tool_choice_accepts_complete_calls_and_rejects_unknown_or_unfinished_calls(tests.rs:365-404) andrequired_tool_choice_fails_without_a_completed_call_for_every_termination(tests.rs:320-363). - OutputLimit/UserStop finish reasons: already
output_limit_marks_only_the_open_response_item_incomplete(tests.rs:1549) andfailures_have_no_success_terminal_and_stops_remain_exact(tests.rs:1461). What is genuinely new is one line per dialect: "unclosed body at EOS yields the same events". One dialect (glm) × Chat buffered+streamed would prove it; the other four are already covered at the parser level by the per-dialect unit tests. Save ~250 lines.
- undeclared-call handling + streamed-vs-buffered argument equality: already
- The same 20-line "for cause in [OutputLimit, UserStop, Cancelled, ExecutionError] { finish is empty }" loop is copy-pasted into four unit tests: argument_tags.rs:574-594, chatml.rs:1068-1088, gemma_call.rs:310-326, minimax_xml.rs:404-420. It exercises one shared branch (
TaggedTools::finishearly return at tagged.rs:302-312) that predates the PR; one instance suffices. Save ~60 lines. - Every one of the four new unit tests re-runs the whole case list at every UTF-8 split (
char_indices()loops: argument_tags.rs:419,470, chatml.rs:969,998, gemma_call.rs:250, minimax_xml.rs:331). Split-invariance of the parser is already covered byevery_utf8_split_preserves_reasoning_tools_and_parameter_types(chatml.rs:363) and the GLM equivalent (argument_tags.rs:318). Keeping one recovery case per dialect per split (not 6-8) saves ~250 lines. Total realistic removal from tests: ~600-700 lines with no loss of a distinct behaviour.
#2 [high] Should fix: ToolDialect::parse is now dead in production; parse_eos adds a required method on top of it
After the PR every production path goes through parse_candidate (tagged.rs:289) or the new parse_eos (tagged.rs:320). ToolDialect::parse (tagged.rs:38) is referenced only by the trait's default parse_candidate (tagged.rs:40-42) and by tests:
- test-only callers: argument_tags.rs:234, gemma_call.rs:159,212, minimax_xml.rs:217,273,277,286,291.
- No
D::parse(...)call exists anywhere in helios/src (search:::parse(bodyhits only the above). All four real dialects overrideparse_candidate(argument_tags.rs:106, chatml.rs:27, minimax_xml.rs:200) or take the default only throughparse(gemma_call.rs:144), and every dialect now also implementsparse_eos, so the strictparsebody is pure dead weight that the PR has to thread through five impls and then keep compiling: - trait decl + doc, helios/src/output/tagged.rs:38
- default
parse_candidatebody, tagged.rs:40-42 - ArgumentTags, argument_tags.rs:103-105
- FunctionTags, chatml.rs:24-26
- GemmaCall, gemma_call.rs:144-146
- MiniMaxXml, minimax_xml.rs:197-199
- PlainText, pipeline.rs:46-48
Making
parse_candidaterequired and droppingfn parse(and its default) removes ~14 production lines plus an entire trait method, and forces the per-dialectparse_body(.., eos: bool)wrappers to shrink to what is actually called. Smaller version, e.g. gemma_call.rs:138-150 becomes: impl super::tagged::ToolDialect for GemmaCall { const NAME: &'static str = "Gemma call"; ... fn parse_candidate(body: &str, tools: &[Value]) -> Result<Option<Vec<(String,String)>>> { Self::parse_body(body, tools, false).map(Some) } fn parse_eos(body: &str, tools: &[Value]) -> Result<Vec<(String,String)>> { Self::parse_body(body, tools, true) } } and the test helpers (GemmaCall::parse,MiniMaxXml::parse,ArgumentTags::parse) callparse_eos/parse_candidateinstead. Saving: ~15 production lines + ~10 test-call lines. Charter: "Look for the smallest footprint in shared code" (charter, How We Work); also "No per-model special cases or flags".
#8 [high] Should fix: logprobs test (+101) asserts machinery the PR never touches; totals
The claim in the PR description — "across buffered and streaming Chat Completions, Messages, and Responses APIs" — adds a 101-line test in helios/src/server/logprobs.rs:362-462 unclosed_glm_tool_call_at_eos_preserves_content_logprobs_and_reasoning_tokens.
Every assertion in it is about machinery the PR does not touch: content logprob arrays, reasoning-token counting, worker-vs-local decoding, Responses streaming. The only PR-dependent part is assert_eq!(response["output"][2]["arguments"], r#"{"text":"ok"}"#) (logprobs.rs:440-442) — the same GLM EOS recovery already asserted per-split in argument_tags.rs:367-505, at the encoder level in protocol/tests.rs:2350+, and with logprobs already covered for the closed GLM call by the existing decoder tests (logprobs.rs:188-360). The test's four-way (worker, streaming) loop multiplies one fact by 4.
Smaller version: nothing; delete the test, or keep it and delete the equivalent GLM case from protocol/tests.rs. Save ~101 lines.
Overall totals for the report:
- tests that repeat existing coverage (protocol/tests.rs 348 + the four per-dialect cause loops ~60 + split loops ~250 + logprobs 101): ~700 lines removable, biggest single win.
- production: dead
fn parse+ its 5 impls (~15), parse_body plumbing (~15),confirmed(~8),callsbump (~6), ToolBegin filter helper (~6), PlainText::parse_eos (~3): ~53 lines. - docs: 11 lines. Total realistic: ~760 of the 1423 added lines, i.e. the change could land at roughly half its size with the same behaviour.
Not a finding (checked, keep): the outer_closed field at tagged.rs:220/292/593-596 is 3 lines and fixes a real double-close bug in the pre-PR code — necessary.
#9 [high] Research summary
Reviewed PR #573 (helios: tolerate omitted closing tags on complete tagged tool calls at EOS; 9 files, +1423/−70) through a subtraction lens, reading each changed function in context plus the tests and docs it supersedes.
The behaviour itself is justified and small (~120 production lines across tagged.rs, argument_tags.rs, chatml.rs, gemma_call.rs, minimax_xml.rs, pipeline.rs, plus 17 doc lines), but the change carries ~1150 lines of tests, most of which repeat coverage that already exists in the same files. My headline finding is that roughly half the diff — about 700 lines of tests, 53 lines of production plumbing and 11 lines of docs, ~760 total — can go with no loss of a distinct behaviour: the one new test in server/protocol/tests.rs re-asserts undeclared-tool, parallel_tool_calls, required/named tool_choice and OutputLimit/UserStop semantics that four existing tests (tests.rs:320, 365, 407, 723) already cover for the same five dialects; the identical "non-EOS causes emit nothing" loop is copy-pasted into four unit tests; and every new per-dialect test re-runs its whole case list at every UTF-8 split, which the existing split-invariance tests already establish.
On the production side the clearest subtraction is that ToolDialect::parse is now dead in production — after this PR every path goes through parse_candidate or the new parse_eos, and parse survives only for test helpers — so making parse_candidate required removes a trait method, its default and five impls, and collapses the four parse_body(.., eos: bool) wrappers the PR had to add. Secondary items: TaggedTools::confirmed duplicates what parse_eos itself already rejects (I verified the undecided-prefix cases per dialect), the new calls += ToolBegin bump in TaggedOutput::finish appears unobservable, and docs/api.md states the new rule twice.
#10 [high] Coverage note: what was examined, what is minimal, and non-findings
Files read in full or in the changed regions, at PR head 09cc524:
- helios/src/output/tagged.rs (whole file, 1005 lines): ToolDialect trait 31-51, ThinkReasoning 53-211, TaggedTools 213-323, TaggedOutput 332-822, partial_marker 824, RawArguments 840-882.
- helios/src/output/argument_tags.rs (1-150, 300-372 + test diff to 615).
- helios/src/output/chatml.rs (17-270, 315-380, 840-905 + test diff to 1089).
- helios/src/output/gemma_call.rs (1-230 + test diff to 327).
- helios/src/output/minimax_xml.rs (1-300 + test diff to 422).
- helios/src/output/pipeline.rs (1-80, 255-340 + test diff to 1476).
- helios/src/server/protocol/tests.rs (17-60, 316-410, 406-614, 720-795, 1540-1580, 2180-2320 + diff 2312-2665).
- helios/src/server/logprobs.rs (diff 359-462).
- docs/api.md 430-540. Also checked for dead paths this leaves behind: helios/src/model/prompt.rs 330-385 (OutputStart::ToolBody producers), helios/src/grammar.rs 340-410 and grammar/strict.rs 1629 (ToolBody grammar branches), helios/src/output/recipient.rs 60-80 (ToolBody state) — none superseded by the PR.
Approximate added-line split (from the diff): tests ≈1150 (protocol/tests.rs 348, logprobs.rs 101, argument_tags 250, chatml 187, gemma 110, minimax 140, pipeline 105); production ≈120 (tagged.rs 38 net, argument_tags 30, chatml 19, gemma 20, minimax 27, pipeline 6); docs 17.
Keep, verified necessary (not findings):
outer_closed(tagged.rs:220, 292, 593-596): 3 lines, fixes a real defect — before the PRouter_tool_pendingwas set wheneverD::FUNCTION.is_some(), even afterD::CLOSEhad already been consumed.emit_calls(tagged.rs:224-246): a genuine dedup, it now has two callers (push 298, finish 321).parse_eoson the trait (tagged.rs:43-45): the no-default choice forces each dialect to state its own structural rule, which is what keeps the change model-agnostic per the charter's "no per-model special cases or flags".- MiniMax
parse_candidatenow routes throughparse_body(.., true)(minimax_xml.rs:200-202): 2 lines that also cover the</tool_call>-closes-without-</invoke>case the PR claims.
Deliberately not flagged:
RawArguments::is_empty(tagged.rs:847-849), one use at chatml.rs:127: 3 lines, no existing equivalent (RawArgumentsexposes onlycontains_key), so inlining saves nothing.- Test strings duplicating fixtures in other modules (e.g. protocol/tests.rs:2360-2390 repeating parser/tool setup from tests.rs:2188-2242): flagging this would be a new helper, which is out of scope for this lens; the duplication finding (entry 1) already covers the excess.
- The per-dialect
strictlookups added in argument_tags.rs:44, gemma_call.rs:123-129, minimax_xml.rs:162-166: each dialect needs its own strict gate on its own body shape; no shared helper would be shorter than the 3-5 lines each. Related prior art worth citing in the report: PR #514 (open) proposed the same GLM lenient-EOS fix with a per-modelconst LENIENT_EOS_CLOSE, and its auto-review was halted as low value. This PR supersedes it with a general mechanism, which is the right shape — and is another reason to keep the mechanism lean rather than keep 700 lines of tests.
#3 [medium] Nit: docs/api.md states the EOS recovery rule twice (~11 lines)
docs/api.md adds the same rule twice:
- docs/api.md:447-451 — general rule ("tagged tool parsers accept a non-strict call whose inner arguments are structurally complete and self-delimited when only its closing wrapper tag is omitted; undecided openers, bare headers … remain errors").
- docs/api.md:514-525 — the same rule again, spelled per dialect, immediately after the per-dialect paragraphs at 501-513 that already say "Function-tag calls complete at
</function>and accept omitted outer tool tags in answer content" etc.
Smaller version: keep 447-451 (it belongs with the parser overview) and delete 514-525; add nothing. The per-dialect exceptions the deleted block repeats ("strict calls missing their wire closer") are covered by the strict tool contract already documented, and the bare-header/trailing-text cases are the same error paths named in 447-451. Save ~11 lines.
#5 [medium] Should fix: TaggedTools::confirmed duplicates what parse_eos checks (~8 lines)
confirmed (helios/src/output/tagged.rs:219 field, :431 init, :698 let mut confirmed = true, :717-722 decision => arm, :760 init, :317 guard) adds ~8 lines and changes the starts_call match from _ => to decision =>. It is redundant with the eos-side validation, verifiable case by case:
starts_call returns None for a dialect only while the text after the opener is still a prefix of what would complete the call:
- GLM (argument_tags.rs:112-137):
Noneonly whennext(text after the function name) is a strict prefix of<arg_key>or</tool_call>— i.e. the buffer ends inside that tag, so no closed<arg_key>…</arg_key><arg_value>…</arg_value>pair can follow.ArgumentTags::parse_body(eos=true)then fails anyway at argument_tags.rs:48-50 (rest.trim().is_empty()), :59-63 (unterminated key) or :84-86 (unterminated value). - FunctionTags (chatml.rs:33-62):
Noneonly when the text ends inside<function=, the header body is empty, or the tail is a prefix of<parameter/</function>. Withallow_unclosed_functionthe recovery branch at chatml.rs:127 needs!arguments.is_empty() && rest.is_empty(); a truncated tail gives either emptyargumentsor a non-emptyrest, so it fails; the three undecided prefixes the PR's own tests name (<tool_call>run,<tool_call>run<arg,<tool_call>run</tool) are already rejected by the eos name/arg checks alone. - GemmaCall / MiniMaxXml default
starts_calltoSome(true), soconfirmedis always true there.
So the guard at tagged.rs:317 (!self.confirmed || in_json_string) can drop the confirmed term: parse_eos already refuses every body that an undecided opener could produce. Everything else in TaggedTools::finish stays. Save ~8 lines plus 2 changed match arms; tests unchanged and still passing (the "undecided opener still errors" assertions remain true via parse_eos).
Caveat to state honestly in the report: the flag is a belt-and-braces guarantee claimed explicitly in the PR description, so this is a simplification to argue in review, not a defect.
#6 [medium] Nit: parse_body(eos: bool) plumbing across four dialects (~15 lines)
Four parallel .._body(body, tools, flag) wrappers were created so parse and the new entry point share one body:
- argument_tags.rs:24-29
parse_body(body, tools, eos)— everyeosuse site is one extraif: :36 name check, :45 strict, :48 empty rest. Cost ~5 lines of plumbing for 2 callers. - gemma_call.rs:108-136
parse_body(body, tools, eos)— only oneif eos && strict(:127). Cost ~4 lines of plumbing for 1 branch. - minimax_xml.rs:143-188
parse_body(body, tools, allow_unclosed_invoke)— flag used at :170 and :178,184. - chatml.rs:85-99
parse_tool(..., allow_unclosed_function)threads the flag through two functions (parse_toolandparse_tool_candidate) purely soparsecan passfalse— andparseitself is now only called from tests (see the dead-parsefinding). Droppingparsecollapses the pair back toparse_tool_candidate(body, tools, wrapped_parameters, allow_unclosed)— or, since the recovery branch is a no-op atrest.is_empty()when the flag is true, to the existing singleparse_tool_candidatewith the branch always live: a candidate whose body is exactly<function=name>+ closed parameters cannot occur on the strict path becausestarts_callalready requires a parameter or</function>after the header, and the strict path is rejected by the!strictterm. Cost ~6 lines of plumbing + 1 parameter. Smaller version for chatml.rs: deletefn parse_tool(85-93) and inline its.ok_or_else(...)at the single remaining call site; delete theallow_unclosed_functionparameter fromparse_toolonly, keep it on the candidate. Total for the finding: ~13-16 production lines.
#4 [low] Nit: duplicated ToolBegin counting and PlainText::parse_eos (~9 lines)
helios/src/output/tagged.rs:524-527 and 579-583 are the same expression twice, copied from the pattern already in the repo at helios/src/output/recipient.rs:503 and 606:
events.iter().filter(|event| matches!(event, Event::ToolBegin { .. })).count()
Replacing the four copies with one 3-line fn begun(events: &[Event]) -> usize (in output.rs next to Event) removes ~6 lines net and one duplicated pattern; nothing else changes.
Also: TaggedTools::emit_calls (tagged.rs:224-246) exists only so push and finish share the event-building block that was previously inline in push. That is a genuine dedup (the PR added a second caller), so it is a fair subtraction already taken; no further action.
helios/src/output/pipeline.rs:49-51 — PlainText::parse_eos duplicates PlainText::parse (46-48) verbatim. It exists only because parse_eos has no default while every real dialect overrides it; give the trait a default that returns the same "tool parsing is not configured" error and the three-line override goes away (folded into the parse/parse_eos cleanup finding).
Save ~6 + ~3 lines.
#7 [low] Nit: TaggedOutput::finish's call counter bump may be unobservable (~6 lines)
helios/src/output/tagged.rs:522-529 adds a 6-line TaggedOutput::finish arm to count Event::ToolBegins emitted by TaggedTools::finish, because finish could not previously emit calls. That bump exists for one reader: the self.calls == 0 newline-trim decision at tagged.rs:730, which runs inside parse — i.e. after finish has already run. TaggedOutput::finish calls self.push(Input::Text("")) before matching Mode::Tool (tagged.rs:519) and immediately returns the result; no parse call follows it. So the increment is invisible to every existing consumer.
Check in review: if no later reader of self.calls is reachable after finish (grep shows only tagged.rs:730/763 and those two increments at 524/579), the arm reduces to:
Mode::Tool => output.extend(self.tool.as_mut().unwrap().finish(cause)?),
restoring the pre-PR line and dropping 6 lines with no behaviour change. Counter-argument the author could make: calls also indexes ToolBegin events inside the finish-emitted vector — but emit_calls starts from self.index, which was already self.calls at construction (tagged.rs:763), so indices are correct without the bump.
Save ~6 lines. Worth raising as "verify this bump is observable; if not, delete it".