Correctness report · NVIDIA/hyperflare-inference #573

Raw Markdown for agents: https://autobot.eidonix.com/p/6f3147db-efad-43d3-a4d8-47ed38271ab3.md

Correctness review — PR 573: helios: tolerate omitted closing tags on complete tagged tool calls at EOS

Link: https://github.com/NVIDIA/hyperflare-inference/pull/573 · head 09cc524, base main, 9 files +1423/−70, CI green, no prior reviews.

Key findings

Change map (what was checked in context)

Verified non-issues (with why they hold)

  1. Anti-fabrication at EOS. finish takes the body, resets search_from/in_json_string/escaped, and rejects !confirmed || in_json_string before delegating (tagged.rs:313-320). confirmed is decision == Some(true) only (:721), so <tool_call>run, <tool_call>run<arg, <tool_call>run</tool (where starts_call returns None) still yield Err("incomplete … tool call"). confirmed is true when the parser started inside a tool body (:431), which is the correct state for OutputStart::ToolBody.
  2. Dialect-level structural guards. GLM requires a name without <, >, or whitespace and a non-empty body (argument_tags.rs:33-50); function tags require at least one closed parameter and an empty remainder (chatml.rs:127-129); MiniMax requires at least one closed element and no leftover text when the invocation is unclosed (minimax_xml.rs:178-180, :184-186); Gemma uses the brace-balanced parser and rejects trailing non-whitespace (gemma_call.rs:131-134). No dialect accepts a bare header.
  3. Non-EOS terminations unchanged. OutputLimit/UserStop/Cancelled/ExecutionError clear the buffer and return no events (tagged.rs:303-312), matching the pre-PR behaviour; http.rs:471-567 still finishes with Cancelled when parallel_tool_calls: false hits the call limit, so an unclosed second call is dropped, not recovered.
  4. Call indexing at finish. TaggedOutput::finish adds the number of emitted ToolBegin events to self.calls (tagged.rs:522-529), which is what keeps the index (:763) and the self.calls == 0 newline-trim branch (:730) correct when the only call is emitted during finish. Without it a recovered call would be numbered 0 again and newline trimming would be wrong. push counting at :579-583 and finish counting at :524-528 cover disjoint event sets, so there is no double count.
  5. strict: true really is visible to the dialects (resolves my earlier caveat). server/request.rs:503-518 builds the presented function object without strict, but grammar/strict.rs:1437-1449 injects function["strict"] = true into that same OutputConfig.content.tools (compile_presented_strict_tools, reached from request.rs:284 with output.as_mut().map(|o| &mut o.content)). For the dialects whose strict grammars are unsupported the request never reaches the parser at all: strict.rs:1482-1484 returns Err("strict function tool schemas are not supported for {other:?} tool syntax"), which covers GemmaCall and MiniMaxXml (model/contract.rs:67 (not opened)). So a strict tool cannot silently be recovered through parse_eos's non-strict path, and argument_tags.rs:44-47, chatml.rs:113,127, gemma_call.rs:147-159, minimax_xml.rs:166,170 all consult a flag that is actually set.
  6. outer_tool_pending. It is now set only when D::FUNCTION.is_some() && !outer_closed (tagged.rs:593-596), where outer_closed is recorded from whether the outer D::CLOSE or the inner function closer terminated the candidate (:275-283, :292). This stops the parser from waiting for a </tool_call> the model already wrote while preserving the wait when only </function>/</invoke> was seen — consistent with the </tool_call> drain path in Mode::Content.
  7. Charter / AGENTS.md fit. The new behaviour is a shared trait method implemented per dialect, with no per-model booleans in shared code (tagged.rs:43-45 plus five impls), matching the charter's "keep the runtime small and model-agnostic … shouldn't accumulate per-model branches" (charter line 12) and AGENTS.md's no-per-model-flags rule. Documentation was updated in the same PR (docs/api.md:444-451, :511-524) and matches the implemented guards.

Findings

Nit 1 — lenient path fires during streaming, not only at EOS (function tags, MiniMax XML)

helios/src/output/chatml.rs:28,127-129 and helios/src/output/minimax_xml.rs:200-201 pass the lenient flag from parse_candidate, which TaggedTools::push calls at the outer closer (tagged.rs:284-296). Consequence: <tool_call><function=lookup><parameter=city>Paris</parameter></tool_call>Done. now succeeds during ordinary generation, where it previously failed with "tool function requires parameter or closing tag" / "unterminated XML invocation". Why it matters: this is a request-visible semantic change outside the "at EOS" contract in the title, and it is the only place where a missing inner closer is tolerated without EOS. It is intended and documented (docs/api.md:511-524) and covered by tests, so no code change is required — suggest stating it explicitly in the PR title/changelog ("… at EOS and at the outer closer for function-tag and MiniMax dialects").

Nit 2 — dialect asymmetry is documented as uniform

GLM argument tags and Gemma recover only at EOS (argument_tags.rs:106-111; gemma_call.rs:147-159), while function tags and MiniMax also recover at </tool_call>. docs/api.md:511-524 describes the recovery rules per dialect but does not flag that two of the four dialects also recover without EOS. Fix: one sentence in docs/api.md (or a table column) noting which dialects tolerate the omitted inner closer at the outer closer.

Open questions / could not be verified

Verdict: no blocking issues; no should-fix issues; two documentation/framing nits and two open questions.