Key findings
PR #573 (helios: tolerate omitted closing tags on complete tagged tool calls at EOS) adds no per-model boolean flags to ToolDialect, keeps the new capability in the shared tagged.rs layer, and gates recovery on strict — a request field, not model identity — so nothing here violates the charter. The problems are conventions and duplication, and there are no blocking issues, but four should-fix items:
- The "find the tool function by name, then read
strict" idiom now has a third and fourth copy (argument_tags.rs, chatml.rs, gemma_call.rs, minimax_xml.rs), with two more variants already in dsml.rs and recipient.rs;stricthas just become load-bearing for the anti-fabrication contract, so four truthiness spellings are a real drift risk. - Every dialect now has
parse/parse_candidate/parse_eoswith three different names for the same leniency flag, and after the changeToolDialect::parsehas no production caller for ArgumentTags, FunctionTags or MiniMaxXml — its only production caller is the trait defaultparse_candidate(tagged.rs:40-42), used by GemmaCall and PlainText. docs/api.mdstates the new EOS recovery contract twice (446-451 and 514-525) with slightly different exclusion lists.- MiniMaxXml's
parse_candidateandparse_eosare now byte-for-byte the same computation, making the trait's documentedNonesignal unreachable for that dialect.
Plus two nits: a copy-pasted ToolBegin counter (tagged.rs:524-527 vs 579-583), and a new trait capability that overlaps the private EOS recovery already in recipient.rs/tml.rs/xtml.rs (not opened) without saying whether those are exempt by design.
Yardstick used: charter line 12 ("Keep the runtime small and model-agnostic … shouldn't accumulate per-model branches"); AGENTS.md:188-193 ("Reject unsupported abstractions and churn … Refactoring must directly support the requested behavior"); docs/design-review.md:47-61 ("use prepared metadata", "Reject per-model boolean policy flags"); .agents/skills/repo-prose/SKILL.md:26-29 (not opened) (documentation is a present-state specification — replace stale claims instead of layering).
Should fix
S1. Strict-tool / function lookup duplicated in four tagged dialects — no shared helper
Files: helios/src/output/argument_tags.rs:40-44, helios/src/output/chatml.rs:109-113, helios/src/output/gemma_call.rs:123-129, helios/src/output/minimax_xml.rs:162-167
All four now spell the same lookup:
let function = tools.iter()
.filter_map(|tool| tool.get("function"))
.find(|function| function.get("name").and_then(Value::as_str) == Some(name));
let strict = function.is_some_and(|f| f["strict"].as_bool() == Some(true));
Two of those four are new in this PR: gemma_call.rs:123-129 was refactored from find(...).and_then(get("parameters")) to keep the function and then test if eos && function.is_some_and(|f| f["strict"].as_bool() == Some(true)) (line 127), and minimax_xml.rs:166 is a newly introduced strict binding on the EOS path.
Two further precedents already express the same concept differently:
helios/src/output/dsml.rs:288-291precomputes strict names withtool.get("function")?+f["strict"].as_bool() == Some(true).helios/src/output/recipient.rs:250-258matches names by direct indexing,tool["function"]["name"] == *name.
Why it matters: the PR makes strict load-bearing for EOS recovery — it is the gate that keeps strict: true calls from being fabricated (see the new parse_eos implementations at argument_tags.rs:45-47, gemma_call.rs:127-129, minimax_xml.rs:170, chatml.rs via allow_unclosed_function). Four independently written truthiness checks of the same request field can drift apart (one accepting "strict": "true", one indexing f["strict"] on a function object it forgot to filter_map, one panicking on a non-function tool entry). This is exactly the duplication docs/design-review.md:47-61 pushes back on ("use prepared metadata", shared mechanisms) even though it is not a per-model flag.
Fix: add pub(super) fn function<'a>(tools: &'a [Value], name: &str) -> Option<&'a Value> and pub(super) fn is_strict(function: Option<&Value>) -> bool in helios/src/output/tagged.rs, next to the existing shared helpers RawArguments (tagged.rs:840-868) and strict_nonstring_raw, and use them in all four dialects — ideally replacing the dsml.rs and recipient.rs spellings too.
S2. parse / parse_candidate / parse_eos triple with three differently named leniency flags; parse becomes test-only
Files: helios/src/output/tagged.rs:38-45, 289, 320; argument_tags.rs:25-29,103-111; chatml.rs:24-32,85-100; gemma_call.rs:144-149; minimax_xml.rs:144-148,197-205; pipeline.rs:46-51
Each dialect now has a third entry point plus a private bool-parameterised body, and the flag carries a different name in each:
- argument_tags.rs:25-29 —
parse_body(body, tools, eos: bool);parse(103-105) →parse_candidate(106-108) passesfalse;parse_eos(109-111) passestrue. - chatml.rs:85-100 —
parse_tool(..., allow_unclosed_function: bool)/parse_tool_candidate(..., allow_unclosed_function: bool);parse(24-26) passesfalse, whileparse_candidate(27-29) andparse_eos(30-32) both passtrue. - gemma_call.rs:144-149 —
parse_body(body, tools, eos: bool);parsefalse,parse_eostrue;parse_candidatefalls back to the trait default → the strictparse. - minimax_xml.rs:144-148 —
parse_body(body, tools, allow_unclosed_invoke: bool);parse_candidate(200-202) andparse_eos(203-205) bothtrue.
Three consequences:
- Same concept, three names (
eos,allow_unclosed_function,allow_unclosed_invoke) for the same "accept the omitted wrapper at natural completion" gate. A reader cannot tell whether they are deliberately per-dialect knobs or one flag with three spellings; chatml and minimax also set ittrueon the push path, argument_tags and gemma only at EOS, so the apparent equivalence is already false in a non-obvious way. ToolDialect::parseis production-dead for three dialects.TaggedTools::finishcalls onlyD::parse_eos(tagged.rs:320) andTaggedTools::pushonlyD::parse_candidate(tagged.rs:289). The only remaining production caller ofparseis the trait defaultparse_candidate(tagged.rs:40-42), which GemmaCall and PlainText use. After this PR,parsein argument_tags.rs:103-105, chatml.rs:24-26 and minimax_xml.rs:197-199 exists only to serve their own unit tests (argument_tags.rs:167, 234, 248; minimax_xml.rs:217, 273, 277, 286, 291; chatml tests). AGENTS.md:188-193 ("Reject unsupported abstractions and churn … Refactoring must directly support the requested behavior") argues against retaining an entry point whose sole consumer is tests of itself; the tests should exercise the real production entry points (parse_candidate/parse_eos).- PlainText repeats its error body.
helios/src/output/pipeline.rs:46-51now has the identicalErr("tool parsing is not configured")twice, once inparseand once inparse_eos. Makingparse_eosmandatory (no default) is the safe choice — a default toparsewould restore the naive path the PR argues against, soTaggedTools::finishwould silently accept promoted openers for any new dialect that forgot to override it — but that rationale is not written down. Say it in the trait doc at tagged.rs:43-45, and have PlainText'sparse_eosdelegate (Self::parse(body, tools)) rather than copy.
Fix: keep exactly two leniency-aware entry points and one name for the flag (allow_unclosed), make the default parse_candidate/parse_eos relationship explicit, delete or reuse the now-test-only parse impls, and document at tagged.rs:43-45 why parse_eos has no default.
S3. MiniMaxXml parse_candidate is now identical to parse_eos
File: helios/src/output/minimax_xml.rs:200-205
fn parse_candidate(body: &str, tools: &[Value]) -> Result<Option<Vec<(String, String)>>> {
Self::parse_body(body, tools, true).map(Some)
}
fn parse_eos(body: &str, tools: &[Value]) -> Result<Vec<(String, String)>> {
Self::parse_body(body, tools, true)
}
parse_body(.., true) returns Ok(calls) or Err, never an empty-None signal, so .map(Some) is unconditionally Some. The trait documents the opposite at tagged.rs:39: "None means the apparent closing tag is text inside a JSON string." That signal is what TaggedTools::push depends on to set in_json_string and keep scanning (tagged.rs:289-295); for MiniMaxXml it is now structurally unreachable. For XML that is plausibly correct — there are no JSON strings to be inside of — but the code gives no way to tell intent from copy-paste, and two identical bodies will drift.
Why it matters: this also changes the non-EOS push path (MiniMax now recovers a </tool_call>-closed invocation with no </invoke> mid-stream, not only at EOS). The PR description says that is intended, but nothing in the code or its doc comment says so.
Fix: collapse to one method — either delete parse_candidate and let parse_eos serve both sites via an explicit delegation, or delete parse_eos and have the trait default wrap parse_candidate. Then update the tagged.rs:39 doc comment so it describes MiniMax's actual behaviour, and add a test asserting the streaming (non-EOS) </tool_call>-without-</invoke> case succeeds, so intent is documented by test.
S4. docs/api.md duplicates the EOS recovery contract and its exclusion list
File: docs/api.md:446-451 and docs/api.md:514-525
The new normative rule appears twice in the same section, in different words:
- 446-451: "At natural completion, 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 without a closing argument delimiter, unclosed arguments, trailing text, and unclosed strict calls remain errors."
- 514-525: the per-dialect restatement — "When a non-strict tagged call omits its closing wrapper tag at natural completion, each dialect accepts it only when its argument body is self-delimited with no trailing non-whitespace: GLM requires … Bare headers without a closing argument delimiter, undecided openers, unclosed arguments, strict calls missing their wire closer, and calls cut off by output limits or stop sequences are never recovered."
The exclusion lists have different membership: the first says "unclosed strict calls", the second "strict calls missing their wire closer"; only the second mentions stop sequences and output limits. Two enumerations of the same set in a normative document is a drift hazard and reads as layered history rather than one present-state specification (.agents/skills/repo-prose/SKILL.md:26-29 (not opened)).
Fix: keep the dialect-specific paragraph (it carries the per-dialect delimiters readers need) and reduce 446-451 to a one-clause pointer, or merge into one paragraph with a single shared exclusion list. docs/api.md:506-508 ("A tag still undecided when generation ends is parsed as an incomplete call") is consistent with the new rule and should stay adjacent to it.
Nits
N1. ToolBegin counting duplicated between parse and finish instead of living with emit_calls
File: helios/src/output/tagged.rs:524-527 vs helios/src/output/tagged.rs:579-583
The PR shared the event builder — TaggedTools::emit_calls (tagged.rs:224-245) — between the push path and the new finish path, but not the counter. The same filter/count now exists twice:
- new:
self.calls += events.iter().filter(|event| matches!(event, Event::ToolBegin { .. })).count();(finish, 524-527) - pre-existing: identical body over
progress.events(parse, 579-583)
recipient.rs:270-287 holds a third copy of the same increment. emit_calls takes &self and indexes with self.index + offset (tagged.rs:230), so the count cannot simply move into it without changing the receiver to &mut self — that is the minimal change, and it also single-sources the ToolBegin/ToolEnd index bookkeeping that Parse's self.index (tagged.rs:222) and self.calls (tagged.rs:730, 763) currently track separately.
N2. parse_eos overlaps per-parser EOS recovery already in recipient/tml/xtml; exemption not stated
Files: helios/src/output/tagged.rs:43-45; helios/src/output/recipient.rs:264-296; helios/src/output/tml.rs:374; helios/src/output/xtml.rs:243
ATEM, TML and XTML already recover unclosed calls at natural EOS with their own private logic — e.g. recipient.rs:270-272 if matches!(self.state, State::Tool) && cause == Termination::Eos with the comment "EOS is suppressed before presentation, so it closes the final tool frame", and tml.rs:374 if cause == Termination::Eos. The new parse_eos is the right home for the tagged dialects (shared layer, per design-review.md principle 3), and unifying ATEM/TML/XTML is out of scope for this PR — but the trait doc is one line (tagged.rs:43-44) and docs/api.md:510-525 scopes the rule to "tagged call"s without saying which parsers are excluded (only the DSML/XTML sentence at api.md:511-512 names any). A reader cannot tell whether ATEM/TML/XTML are exempt by design or by omission — and they are not equivalent: recipient.rs applies no strict gate and no self-delimiter check.
Fix: one sentence in the parse_eos doc comment (tagged.rs:43-45) noting that recipient/TML/XTML own their envelope state machines and keep their own EOS handling, plus the matching clause in api.md.
What I could not settle
- Whether
ToolDialect::parseis meant to stay as a public, test-only entry point (S2). A grep of production callers shows only the trait defaultparse_candidate(tagged.rs:40-42); dropping the three now-test-only impls and moving their unit tests ontoparse_candidate/parse_eoswould settle it. This is the one finding where maintainer intent decides between "should fix" and "fine as is". - Whether MiniMax deliberately became lenient on the non-EOS
</tool_call>push path (S3). The PR description says yes; neither the code nor the trait doc says so. A test asserting the</tool_call>-closed-but-no-</invoke>case succeeds during streaming (not just at EOS) would document the intent.
Scope note
All nine changed files were read in context at the PR head (not just the diff): tagged.rs, argument_tags.rs, chatml.rs, gemma_call.rs, minimax_xml.rs, pipeline.rs, server/logprobs.rs, server/protocol/tests.rs, docs/api.md, with callers followed for the behaviour change in TaggedTools::finish (tagged.rs:302-322) and TaggedOutput::finish (tagged.rs:506-540), and the closest precedents read (dsml.rs:288-291, recipient.rs:245-296, tml.rs:368-382, xtml.rs:235-250). No blocking findings; nothing in the change violates a hard rule (no per-model boolean flags on ToolDialect; the capability sits in the shared tagged.rs layer; strict is a request field, not model identity).