Recommendation: Ready To Merge
PR #573 (already merged at 701ddd4) is sound, well-verified, and free of correctness, safety, or contract regressions: it adds flag-free EOS wrapper recovery through a shared ToolDialect::parse_eos method while preserving anti-fabrication (confirmed, in_json_string, self-delimited body checks), strict: true enforcement, and non-EOS omission guarantees, and fixes a pre-existing outer_tool_pending double-close bug. Zero blockers or should-fix defects survive verification; only one small helper deduplication and two minor nits remain as optional follow-ups.
Blockers
None.
Should Fix
None.
Subtract / Simplify
- Deduplicate the 4×
toolsfunction-lookup andstrictcheck intohelios/src/output/tagged.rshelios/src/output/argument_tags.rs:40-44,helios/src/output/chatml.rs:109-113,helios/src/output/gemma_call.rs:123-127, andhelios/src/output/minimax_xml.rs:162-166all repeat the exact same five lines to look up a function spec by name and readf["strict"].as_bool() == Some(true).- All four copies are currently consistent and safe, so this is not a defect today, but extracting a single
pub(super) fn function_spec<'a>(tools: &'a [Value], name: &str) -> (Option<&'a Value>, bool)(ortool_function+is_strict) inhelios/src/output/tagged.rsalongsidestrict_nonstring_rawandcontainer_parameterkeeps the load-bearingstrictanti-fabrication gate in one place.
Nits
- Doubled
"call"in Gemma strict-EOS error string (helios/src/output/gemma_call.rs:128)Err("incomplete strict Gemma call tool call".into())repeats"call"(fromD::NAME = "Gemma call"). Consider"incomplete strict Gemma tool call"or"strict Gemma call requires <tool_call|>".
- Share the name-delimiter predicate in
helios/src/output/argument_tags.rs:36,119parse_body(:36:c == '<' || c == '>' || c.is_whitespace()) andstarts_call(:119:c == '<' || c == '>' || c.is_whitespace()) spell the same character predicate twice; a 3-linefn is_name_delimiter(c: char) -> boolkeeps them in sync.
Verified passes
- Anti-fabrication &
confirmed/in_json_stringgating (helios/src/output/tagged.rs:141-156,247-261,339-353,462,746-755):- Undecided openers promoted during
TaggedOutput::finish(self.finishing == true)—both fromMode::Contentand viaThinkReasoning::pushemitting aremainderback intoMode::Content—enterMode::Toolwithconfirmed = false, soTaggedTools::eos_decisionreturnsEosDecision::RejectatTermination::Eos. - Unfinished JSON strings (
in_json_string == true) are also rejected at EOS even whenconfirmed == true. - All non-EOS terminations (
OutputLimit,UserStop,Cancelled,ExecutionError) map toEosDecision::Omit.
- Undecided openers promoted during
- Per-dialect structural completeness &
strict: truegates:ArgumentTags(helios/src/output/argument_tags.rs:25-95): requires non-empty valid function name (no<,>, whitespace),!strict, non-empty argument body with ≥1 closed<arg_key>...</arg_key><arg_value>...</arg_value>pair, and no trailing non-whitespace.FunctionTags(helios/src/output/chatml.rs:95-178): allows omitted</function>only when!strict,!arguments.is_empty(), andrest.is_empty()after trimming.GemmaCall(helios/src/output/gemma_call.rs:109-136): rejectsstrict: trueat EOS and requires a brace-balanced{...}object with closed<|"|>strings and no trailing non-whitespace.MiniMaxXml(helios/src/output/minimax_xml.rs:144-188): allows omitted</invoke>only when!strict, ≥1 closed parameter element is parsed (!values.is_empty()), andparameters.trim().is_empty(), while rejecting empty<tool_call></tool_call>blocks (allow_unclosed_invoke && calls.is_empty()).
outer_closeddouble-close fix (helios/src/output/tagged.rs:231-244,319-330,624-627):select_candidatedistinguishes outerD::CLOSEfrom innerD::FUNCTIONcloser soouter_tool_pendingis only set when the inner closer ended the call; verified by the duplicate-</tool_call>test athelios/src/output/chatml.rs:941-946.partial_marker& Kani proofs (helios/src/output/tagged.rs:855-868,helios/src/output/tagged/kani_proofs.rs:1-176,helios/src/lib.rs:20-22):partial_markerreverse-scans on UTF-8 char boundaries;pub mod outputis properly gated forcfg(kani)with#[cfg(feature = "server")]ongrammar_envelope(tagged.rs:474), and all four Kani harnesses match the documented bounds inverification/helios-lifecycle/README.md:385-473.- Documentation & sibling-parser alignment (
docs/api.md:446-451,511-525): Accurately states the per-dialect rules (including</tool_call>-closedFunctionTags/MiniMaxXml), and sibling parsers behave consistently with the doc:dsml.rs:379-380andxtml.rs:242-247reject unclosed tool blocks at EOS (explicitly noted atdocs/api.md:511-512), whilerecipient.rs:270-272andtml.rs:374-376already handle EOS completion in their own state machines.
Dropped on verification
- B1 (Four dialects relaxed without captured generations; #514 precedent): Dropped — PR #573 was authored and merged by project owner
lukealonso(docs/design-review.md:22-23), deliberately superseding #514 (which failed auto-review for adding a GLM-onlyconst LENIENT_EOS_CLOSEboolean flag and blindly callingD::parsewithoutconfirmed/strictguards); #67 already measured Qwen emitting EOS where</tool_call>would follow, #514 reported GLM doing the same, the PR honestly discloses unrun checkpoint/GPU checks, and the structural/strictgates prevent call fabrication. - S1 (
parse_eosduplication / unreachableNoneinMiniMaxXml::parse_candidate/ missing MiniMax</tool_call>test): Dropped — keepingparse_eosrequired onToolDialectprevents silently lenient future dialects;MiniMaxXmlis XML and previously inherited the trait default.map(Some)(tagged.rs:40-42) soin_json_stringwas never reachable for it; and MiniMax's</tool_call>-without-</invoke>streaming case is already tested at every UTF-8 split inhelios/src/output/minimax_xml.rs:320-324. - S2 (
strictlookup duplication as Should Fix): Downgraded to Subtract / Simplify #1 — all four copies are currently identical and safe (filter_map(|t| t.get("function"))+as_bool() == Some(true)), so there is no active bug. - S3 (
docs/api.mdduplicate rule / omittedCancelled/ExecutionError/ over-general "tagged tool parsers"): Dropped —docs/api.md:447-451is the overview paragraph and:514-525explicitly enumerates all four tagged dialects (GLM, function-tag, Gemma 4, MiniMax XML);Cancelled/ExecutionErrorabort the stream rather than returning a response; andrecipient.rs:270-272andtml.rs:374-376already handle EOS completion whiledsml.rs:379-380andxtml.rs:242-247are explicitly excluded at:511-512(refuting the upstream Value Prop claim thatrecipient/tmllack EOS handling). - S4 (Mid-stream leniency at
</tool_call>not reflected in title): Dropped — explicitly documented in the PR description ("What changed" and "Claimed result"),docs/api.md:518-522, and tests (chatml.rs:934-946,minimax_xml.rs:321-324). - X1 (Delete ~700 lines of protocol, logprob, split, and non-EOS tests): Dropped —
protocol/tests.rs:2350-2664andlogprobs.rs:362-463validate real streaming-encoder, control-semantics, worker/local stop-filter, content-logprob, and reasoning-token invariants when calls are emitted fromfinish(Termination::Eos)instead ofpush, and the per-dialect suites back thecargo-mutantscoverage; deleting useful unit/protocol tests is counterproductive. - X2 (Unify
eos/allow_unclosed_function/allow_unclosed_invokenames and removeToolDialect::parse): Dropped — the parameter names accurately reflect distinct semantics (ArgumentTags/GemmaCallonly relax at EOS, whereasFunctionTags/MiniMaxXmlalso relax at</tool_call>), andToolDialect::parseis the primary required method of apub traitused byGemmaCall,PlainText, and tests. - N2 ("Dead" resets in
TaggedTools::finish,tagged.rs:342-344): Dropped — resettingself.search_from = 0alongsidestd::mem::take(&mut self.buffer)preserves theself.search_from <= self.buffer.len()invariant required by&self.buffer[self.search_from..]attagged.rs:314. - N3(i) (
ToolBegincounting duplicated inrecipient.rs:273-274): Dropped —recipient.rs:272-274incrementsself.calls += 1inside a call-emission loop rather than filteringEvent::ToolBegin; only two 4-line expressions exist intagged.rs:555-558,610-614. - N4 (Mention
recipient/tml/xtmlinToolDialect::parse_eosdoc comment): Dropped — those sibling parsers do not implementToolDialect, so cross-referencing them inside the trait doc adds noise. - N5 (PR description "What changed" omits
kani_proofs.rs): Dropped (factually false) — verified via PR #573's current description (701ddd4), which explicitly listshelios/src/output/tagged/kani_proofs.rs,helios/src/lib.rs,.github/workflows/helios-lifecycle.yml(not opened), andverification/helios-lifecycle/README.mdalong with the Kani andcargo-mutantsevidence. - Value Prop claim that the
outer_closedduplicate-close-tag flip is untested: Dropped (factually false) — explicitly tested at every UTF-8 split inhelios/src/output/chatml.rs:941-946.