#1 [high] Lens D: chatml/minimax parse_eos duplicate parse_candidate; PlainText duplicates parse
helios/src/output/chatml.rs:24-32 + 85-100: parse_candidate = parse_tool_candidate(body, tools, WRAPPING_NEWLINES, true); parse_eos = parse_tool(body, tools, WRAP, true) = parse_tool_candidate(...,true).ok_or("incomplete JSON parameter"). Identical behavior/flag. So parse_eos == Self::parse_candidate(...)?.ok_or_else(...). With that rewrite, parse_tool's 4th bool param is only ever passed false and can be deleted.
helios/src/output/minimax_xml.rs:200-205: parse_candidate = parse_body(body,tools,true).map(Some); parse_eos = parse_body(body,tools,true). Literally the same call/flag. → parse_eos = Self::parse_candidate(...)?.ok_or_else(|| "XML tool call requires an invoke tag").
helios/src/output/pipeline.rs:49-51: PlainText parse_eos repeats parse's body verbatim (Err "tool parsing is not configured") → Self::parse(body, tools) or leave to a default.
Net: semantics then live in one place per dialect; three impls shrink to one line each. Keep the trait method required (explicit opt-in is right for anti-fabrication); only the duplicate bodies go.
#2 [high] PR #573 lens D findings: duplicate parse_eos paths, duplicated test loops, dead resets, prose
Lens D (simplicity) findings for PR #573 (head 09cc524), all verified in code.
F1 should-fix — duplicated parse_eos bodies (three of five dialects).
- helios/src/output/chatml.rs:27-32: parse_candidate = parse_tool_candidate(body, tools, WRAP, true)?.map(|c| vec![c]); parse_eos = Ok(vec![parse_tool(body, tools, WRAP, true)?]) and parse_tool (chatml.rs:85-93) is just parse_tool_candidate(..., allow)?.ok_or("incomplete JSON parameter"). So parse_eos ≡ Self::parse_candidate(body, tools)?.ok_or_else(|| "incomplete JSON parameter".into()). Once written that way, the new 4th parameter
allow_unclosed_functionhas no call site passing false except the two test calls at chatml.rs:407-415, so it can be deleted from parse_tool/parse_tool_candidate. - helios/src/output/minimax_xml.rs:200-205: parse_candidate = parse_body(body,tools,true).map(Some) and parse_eos = parse_body(body,tools,true) — the same call with the same flag. → parse_eos = Self::parse_candidate(body, tools)?.ok_or_else(|| "XML tool call requires an invoke tag".into()).
- helios/src/output/pipeline.rs:49-51: PlainText::parse_eos repeats parse's body verbatim →
Self::parse(body, tools)or a=> Self::parsedefault is unnecessary; one line. Keep the trait method required (no default) — an explicit opt-in per dialect is the anti-fabrication contract. Only the duplicate bodies and the chatml/minimax boolean plumbing should go. Contrast argument_tags.rs:25-110, where theeosbool carries real distinct checks (name character set, nonempty body, strict rejection) — that one is justified.
F2 should-fix — the per-dialect "non-EOS termination causes always omit" loops are duplicated four times and already covered elsewhere. Loops at argument_tags.rs:599-611, chatml.rs:1069-1086, gemma_call.rs:308-324, minimax_xml.rs:401-419 are the same four-cause loop over the same assertion. helios/src/server/protocol/tests.rs:2604-2652 (steps 5 and 6 of the new test) already asserts OutputLimit and UserStop omission of a structurally complete unclosed call for all five dialects across Chat/Messages/Responses, and chatml.rs:868-900 already asserts Cancelled/ExecutionError/UserStop/OutputLimit omission. Fix: delete the four loops, or keep one shared helper invoked once per dialect. Cancelled/ExecutionError keep coverage from chatml.rs:886-899 plus the early-return path in tagged.rs:302-312.
F3 nit — dead resets in TaggedTools::finish, helios/src/output/tagged.rs:313-316: self.buffer is taken, and then self.search_from = 0; and self.escaped = false; have no reader (search_from only indexes self.buffer; escaped only feeds the in_json_string scan). in_json_string must be read before the reset because line 317 tests it, so keep that. Delete search_from/escaped resets.
F4 nit — error prose, gemma_call.rs:127-129: "incomplete strict Gemma call tool call" reads as a garbled variant of the dialect NAME concatenation and does not name the missing condition. Per repo-prose (state the missing condition) and AGENTS.md L45-50: e.g. "strict Gemma call requires <tool_call|>". Same shape at argument_tags.rs:44-47 ("incomplete strict GLM tool call") which is at least grammatical; align the two.
F5 nit — docs/api.md duplicates the recovery rule: the general statement at 447-451 and the per-dialect statement at 514-525 restate the same rule. Repo-prose asks for present-state specification without layering; keep the per-dialect paragraph (it is the specific one) and reduce 447-451 to a pointer, or drop the mid-paragraph restatement. Also 522-525 repeats "undecided openers... strict calls" already in 449-451.
F6 nit — argument_tags.rs:36 repeats the delimiter-character test from starts_call (argument_tags.rs:119: c == '<' || c == '>' || c.is_whitespace()). One small helper (e.g. fn name_char(c: char) -> bool) removes the second spelling of the same rule.
F7 nit — pipeline.rs:1430-1445 (new test, plain-text </think> block) asserts unchanged behavior (plain-text delimiter stays reasoning and yields no tool call), which existing terminal-cause tests already cover; it does not prove anything the PR changes. Trimming is optional; the token-gated and Gemma blocks do prove new behavior.
#3 [high] Research summary
Reviewed PR #573 through the simplicity lens: all nine changed files read 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 trait's other implementors, TaggedOutput's callers, Accumulator, and the existing tests the new ones overlap.
Main finding (should fix): three of the five new ToolDialect::parse_eos implementations are byte-equivalent to an existing path, so the same acceptance rule is now spelled in two places per dialect. In chatml.rs:27-32 parse_eos is literally parse_candidate(..., true) wrapped in parse_tool(..., true), and parse_tool's new allow_unclosed_function parameter is then always true in production code — the parameter can be deleted. In minimax_xml.rs:200-205 parse_candidate and parse_eos are the same parse_body(body, tools, true) call with the same flag. In pipeline.rs:49-51 PlainText::parse_eos repeats parse's body verbatim. Keeping the trait method required is right (the explicit per-dialect opt-in is what prevents fabrication); only the duplicated bodies and the two new bool parameters should go. By contrast, argument_tags.rs:25-110's eos flag carries genuinely distinct checks and is justified.
Also found: the "non-EOS termination causes always omit unclosed calls" loop is copy-pasted four times (argument_tags.rs:599-611, chatml.rs:1069-1086, gemma_call.rs:308-324, minimax_xml.rs:401-419) even though the new protocol test at tests.rs:2604-2652 already asserts OutputLimit and UserStop omission for all five dialects across all three protocols, and chatml.rs:868-899 already covers the other causes. Remaining nits: dead search_from/escaped resets in TaggedTools::finish (tagged.rs:313-316), a garbled error string at gemma_call.rs:127-129, the recovery rule stated twice in docs/api.md (447-451 and 514-525), the tool-name character rule duplicated at argument_tags.rs:36 and :119, and one new test block (pipeline.rs plain-text </think>) that only re-asserts unchanged behavior. Details and the smaller versions are in the scratchpad.
#4 [medium] PR #573 lens D: what is clean / correctly smaller (no findings)
Lens D (simplicity) — checked and found no finding. Report should state these plainly so the findings list is not read as "the design is over-built".
- helios/src/output/tagged.rs:225-245:
TaggedTools::emit_callsis a real dedupe — the same 20-line enumerate/flat_map block existed inpushand is now shared bypush(line 298) andfinish(line 321). Justified removal, not churn. - tagged.rs:219, 698-722:
confirmeddoes not introduce a second decision path. It records the existingD::starts_callverdict (decision == Some(true)) thatparsealready computed and used to choose the marker;OutputStart::ToolBodysets it true at tagged.rs:431 because that mode starts inside a confirmed body. No new predicate, no per-model flag — compliant with the charter's "no per-model special cases or flags" (charter L~12 in the review standards) and design-review principle 3. - tagged.rs:220, 593-596:
outer_closedfixes a real defect (outer_tool_pending was set even when D::CLOSE had already been consumed) with one bool that mirrors the tuple element already produced at tagged.rs:275-283. It cannot be derived fromD::FUNCTION.is_some(); the information is per-call state. - tagged.rs:520-529: the
calls += ToolBegin countinfinishfixes call indexing for EOS-emitted calls (index comes fromself.callsat tagged.rs:763 / emit_calls offset). Same counting already happens on the push path at tagged.rs:579-583; the fix makes finish consistent rather than adding a path. - tagged.rs:847-849:
RawArguments::is_emptyhas exactly the two consumers it needs (chatml.rs:127) — not speculative API. - Each new
parse_eosis 1-5 lines except argument_tags/minimax which reuse their existing body parser; none adds a new parsing engine. The alternative (lenientparseat EOS) is genuinely unsafe, as the PR description argues and starts_call behaviour confirms. - docs: the per-dialect paragraph added at docs/api.md:514-525 is warranted (it names the wire closers per dialect); only its overlap with 447-451 is a nit.
- New tests are behaviour tests through the production entry points (OutputPipeline, Decoder, Encoder), not source-text checks — compliant with AGENTS.md "Require focused, meaningful validation".