#1 [high] Should fix: strict-tool/function lookup duplicated in four tagged dialects
PR 573 adds a third and fourth copy of the same tool lookup, and each copy newly reads strict on the EOS path.
Sites (all at PR head):
- helios/src/output/argument_tags.rs:40-44 (
filter_map(|tool| tool.get("function")).find(|function| function.get("name").and_then(Value::as_str) == Some(name));f["strict"].as_bool() == Some(true)) - helios/src/output/chatml.rs:109-113 (identical)
- helios/src/output/gemma_call.rs:123-129 (new: refactored from
find(...).and_then(get("parameters"))to keep the function, thenif eos && function.is_some_and(|f| f["strict"].as_bool() == Some(true))) - helios/src/output/minimax_xml.rs:162-167 (new
strictbinding on the EOS path)
Precedents showing the same concept is already expressed four different ways:
- helios/src/output/dsml.rs:288-291 collects strict names as
tool.get("function")?+f["strict"].as_bool() == Some(true) - helios/src/output/recipient.rs:250-258 matches names by direct indexing
tool["function"]["name"] == *name
Why it matters: strict is now load-bearing for EOS recovery (the anti-fabrication contract); four independent truthiness spellings of the same request field can drift (e.g. one accepting "strict": "true", or one omitting filter_map(get("function")) and panicking on a non-function tool entry). It is also the pattern the charter's "Keep the runtime small and model-agnostic" and design-review principle 3 (shared mechanisms, no per-model branches) push back on.
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 RawArguments/strict_nonstring_raw (tagged.rs:840-898), and use them in all four dialects (and ideally dsml.rs).
#2 [high] Should fix: parse/parse_candidate/parse_eos triple with three differently named leniency bools
The PR gives every dialect a third entry point plus a private bool-parameterised body, and the three copies are named and wired inconsistently:
- helios/src/output/argument_tags.rs:25-29
parse_body(body, tools, eos: bool);parse(103-105) delegates toparse_candidate(106-108), which passesfalse;parse_eos(109-111) passestrue. - helios/src/output/chatml.rs:85-100
parse_tool(..., allow_unclosed_function: bool)/parse_tool_candidate(..., allow_unclosed_function: bool);parsepassesfalse, butparse_candidate(27-29) andparse_eos(30-32) both passtrue. - helios/src/output/gemma_call.rs:144-149
parse_body(body, tools, eos: bool);parsefalse,parse_eostrue;parse_candidateleft as the trait default →parse(strict). - helios/src/output/minimax_xml.rs:144-148
parse_body(body, tools, allow_unclosed_invoke: bool);parse_candidate(200-202) andparse_eos(203-205) bothtrue.
Consequences worth fixing:
- Same flag, 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 the flags are meant to be the same or per-dialect knobs. - After the change,
TaggedTools::finishcalls onlyD::parse_eos(helios/src/output/tagged.rs:320) andTaggedTools::pushonlyD::parse_candidate(tagged.rs:289). SoToolDialect::parseis production-dead for ArgumentTags, FunctionTags and MiniMaxXml (its only production caller is the trait's defaultparse_candidate, used by GemmaCall and PlainText, tagged.rs:40-42). The remainingparseimpls for those three exist only to serve their own unit tests (argument_tags.rs:167/234/248, minimax_xml.rs:217/273/277/286/291, chatml tests). That is exactly the kind of retained duplicate surface AGENTS.md ("Reject unsupported abstractions and churn"; "Refactoring must directly support the requested behavior") pushes back on: either dropparsein favour ofparse_candidate/parse_eosand update the tests to exercise the real entry points, or giveparsea real caller. - PlainText (helios/src/output/pipeline.rs:46-51) now repeats the identical
Err("tool parsing is not configured")body twice; a trait defaultparse_eosreturning that same error (orSelf::parse) would remove the copy. Note the PR deliberately makesparse_eosmandatory with no default, which is defensible (a default toparsewould restore the unsafe naive path the description argues against) — worth saying in the trait doc comment at tagged.rs:43-45 rather than leaving it implicit.
#7 [high] Research summary
Reviewed PR 573 (helios: tolerate omitted closing tags on complete tagged tool calls at EOS) through the conventions-and-duplication lens. Read the charter, AGENTS.md, docs/design-review.md, the repo-prose skill, the full diff, and all nine changed files in context (tagged.rs, argument_tags.rs, chatml.rs, gemma_call.rs, minimax_xml.rs, pipeline.rs, logprobs.rs, protocol/tests.rs, docs/api.md), plus the closest precedents (dsml.rs, recipient.rs, tml.rs (not opened), xtml.rs).
Six findings recorded in the scratchpad, no blocking issues: (1) should fix — the tool-by-name lookup and f["strict"] truthiness idiom now has a third and fourth copy in argument_tags.rs:40-44, chatml.rs:109-113, gemma_call.rs:123-129 and minimax_xml.rs:162-167, with dsml.rs:288-291 and recipient.rs:250-258 already spelling the same concept differently, while strict has become load-bearing for the anti-fabrication contract; no shared helper exists. (2) should fix — the parse/parse_candidate/parse_eos triple carries three different names for the same leniency flag (eos, allow_unclosed_function, allow_unclosed_invoke), and after the change ToolDialect::parse is production-dead for ArgumentTags, FunctionTags and MiniMaxXml since TaggedTools calls only parse_candidate and parse_eos. (3) should fix — docs/api.md:446-451 and 514-525 state the recovery rule and its exclusion list twice with slightly different membership. (4) should fix — MiniMaxXml's parse_candidate and parse_eos are now byte-for-byte the same computation with None unreachable, collapsing the trait's text-inside-JSON-string signal. (5) nit — the new ToolBegin counter in TaggedOutput::finish (tagged.rs:522-529) duplicates the one in parse (tagged.rs:579-583); emit_calls was shared but the counting was not. (6) nit — parse_eos overlaps the private EOS recovery already in recipient.rs, tml.rs (not opened) and xtml.rs, and neither the trait doc nor docs/api.md says whether those dialects are exempt by design or omission.
#8 [high] Wrap-up: review scope, verified state, and what was not settled
Review of PR 573, conventions-and-duplication lens. Completed: all 9 changed files read in context at the PR head (not just the diff), with callers followed for the behaviour change in TaggedTools::finish (helios/src/output/tagged.rs:302-322) and TaggedOutput::finish (tagged.rs:506-540).
Rules read and used as the yardstick:
- Charter: "Keep the runtime small and model-agnostic"; helios "shouldn't accumulate per-model branches (#267, #334)".
- AGENTS.md:155-213 (contribution scope), including "Reject unsupported abstractions and churn" and "Refactoring must directly support the requested behavior".
- docs/design-review.md principle 3 ("Express differences through ... prepared metadata reusable across models"; "Reject per-model boolean policy flags") and principle 16.
- .agents/skills/repo-prose/SKILL.md:26-29 ("Documentation is a present-state specification ... Replace stale claims instead of layering history on top").
Findings and severities, all confirmed in code (details in entries 1-6):
- Should fix - tool lookup +
stricttruthiness now 4 copies across argument_tags.rs:40-44, chatml.rs:109-113, gemma_call.rs:123-129, minimax_xml.rs:162-167; precedent variants at dsml.rs:288-291, recipient.rs:250-258. - Should fix -
parse/parse_candidate/parse_eostriple, three names for one flag;ToolDialect::parseproduction-dead for three dialects (only caller left is the trait default at tagged.rs:40-42). - Should fix - docs/api.md:446-451 vs 514-525 duplicate the contract and the exclusion list with different membership.
- Should fix - minimax_xml.rs:200-205
parse_candidateidentical toparse_eos;Noneunreachable. - Nit - ToolBegin counting duplicated: tagged.rs:522-529 vs 579-583;
emit_calls(tagged.rs:224-245) was shared but the counter was not, and its&selfreceiver blocks folding the counter in. - Nit -
parse_eosoverlaps EOS recovery already in recipient.rs:264-296, tml.rs:374, xtml.rs:243; exemption not stated in the trait doc (tagged.rs:43-45) or in docs/api.md:510-525.
No blocking findings. Nothing in the change violates a hard rule (no per-model boolean flags on ToolDialect; the shared layer owns the capability; strict is a request field, not model identity), so the findings are convention and duplication, not charter violations.
Open items I could not settle from code alone:
- Whether
ToolDialect::parseis intended to stay as a public/test-only entry point. A grep of production callers shows only the defaultparse_candidate, so dropping it and moving the argument_tags/minimax_xml/chatml unit tests ontoparse_candidate/parse_eoswould settle it. This is the one finding where a maintainer's intent decides between "should fix" and "fine as is". - Whether MiniMaxXml deliberately became lenient on the non-EOS
</tool_call>push path (parse_candidatenow passingtrue). The PR description says yes; the trait doc comment at tagged.rs:39 was not updated to match, so a reader of the code alone would conclude it was accidental. A single test asserting the</tool_call>-closed-but-no-</invoke>case succeeds during streaming (not just at EOS) would document the intent.
#3 [medium] Nit: ToolBegin counting duplicated between parse and finish instead of in emit_calls
Two independent implementations of the same "count the ToolBegin events I just emitted" loop now exist in the same file:
- Pre-existing: helios/src/output/tagged.rs:579-583 inside
TaggedOutput::parse(self.calls += progress.events.iter().filter(|event| matches!(event, Event::ToolBegin { .. })).count();) - New: helios/src/output/tagged.rs:522-529 inside
TaggedOutput::finish(identical body, overeventsinstead ofprogress.events)
The PR adds TaggedTools::emit_calls (tagged.rs:224-245) so both emission points share one builder, but not a shared counter, so the increment remains copy-pasted. helios/src/output/recipient.rs:270-287 does the third copy of the pattern (self.calls += 1 per call).
Fix: fold the count into the shared helper, e.g. fn emit_calls(&mut self, calls) -> Vec<Event> that also advances self.index/an internal count, or a small fn begun(events: &[Event]) -> usize next to emit_calls. Note emit_calls takes &self (tagged.rs:225) and indexes with self.index + offset, so the counter cannot simply live in it without changing the receiver to &mut self — that is the minimal change and it also makes ToolEnd/ToolBegin index bookkeeping single-sourced.
#4 [medium] Nit: new parse_eos capability overlaps existing per-parser EOS recovery in recipient/tml/xtml
The other tag-dialect parsers already had natural-completion recovery and encode it as their own private logic; the new parse_eos does not reuse or unify with them:
- helios/src/output/recipient.rs:264-296: ATEM already parses the buffered frame at
Termination::Eos(if matches!(self.state, State::Tool) && cause == Termination::Eos) and emits calls, with an explicit comment that EOS is suppressed before presentation. Same "recover at natural EOS" semantics as the newparse_eos, different mechanism (nostrictgate, no self-delimiter check). - helios/src/output/tml.rs:374 and helios/src/output/xtml.rs:243 already branch on
cause == Termination::Eos. - helios/src/output/tagged.rs:199-210 (
ThinkReasoning::finish) and tagged.rs:302-322 both key offTerminationrather than exposing a named capability.
Reviewers of the conventions lens should note the inconsistency, not necessarily demand unification: parse_eos is a trait capability (correct place, in the shared tagged.rs layer per design-review principle 3) while ATEM/XTML are separate parsers. But the new trait method has only one doc line (tagged.rs:43-44) and no statement of why ATEM/TML/XTML do not implement it, so a reader cannot tell whether those dialects are exempt by design or by omission. docs/api.md:514-525 also scopes the rule to "tagged call"s without naming which parsers are excluded beyond the DeepSeek DSML/XTML sentence at line 511-512.
#5 [medium] Should fix: docs/api.md duplicates the EOS recovery contract and its exclusion list
docs/api.md now states the same recovery contract twice, in different words, in the same section:
- docs/api.md:446-451 (new): "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."
- docs/api.md:514-525 (new): the per-dialect restatement of the same rule ("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 list is enumerated twice with slightly different membership: the first list has "unclosed strict calls", the second "strict calls missing their wire closer"; only the second mentions stop sequences. That is a drift risk in a normative doc and reads as layered history rather than one present-state specification (.agents/skills/repo-prose/SKILL.md:26-29: documentation is a present-state specification, replace stale claims instead of layering).
Fix: keep the dialect-specific paragraph (it carries the per-dialect delimiters a reader needs) and reduce the first mention at 446-451 to a one-clause pointer to it, or fold both into one paragraph with a single shared exclusion list.
Also note docs/api.md:506-508 still says "A tag still undecided when generation ends is parsed as an incomplete call", which is correct and consistent — good, no contradiction there; worth keeping that sentence adjacent to the new rules.
#6 [medium] Should fix: MiniMaxXml parse_candidate is now identical to parse_eos
helios/src/output/minimax_xml.rs:200-205: parse_candidate and parse_eos are now literally the same computation:
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) never returns None... it returns Ok(calls) or Err, so .map(Some) is Some unconditionally. The consequence is that MiniMax's parse_candidate can no longer signal "this close tag was text, keep scanning" (the None that TaggedTools::push uses at tagged.rs:289-295 to set in_json_string); that signalling is now structurally impossible for this dialect. That may be correct (XML has no JSON strings), but it means the two methods should be one: parse_candidate should be the trait default or delegate to parse_eos. As written, the reviewer cannot tell whether the two identical bodies are intentional or a copy that will drift apart. Also note MiniMax's parse_candidate is now lenient on the push path as well, not only at EOS — the PR description says this is intended ("updated parse_candidate to allow non-strict invocations missing </invoke> at </tool_call>"), but the doc line at tagged.rs:39 ("None means the apparent closing tag is text inside a JSON string") no longer describes any MiniMax behaviour.
Fix: delete parse_candidate for MiniMaxXml and let the default (Self::parse(body, tools).map(Some) → parse_body(body, tools, false)) be replaced by an explicit one-line delegation to parse_eos, or drop parse_eos for this dialect and reuse parse_candidate. Either way, one method.