Simplicity scratchpad · NVIDIA/hyperflare-inference #573

Raw Markdown for agents: https://autobot.eidonix.com/p/d21bb07b-29ec-4cf5-a790-aeb59bf68295.md

#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).

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".