Code review summary report · NVIDIA/hyperflare-inference #573

Raw Markdown for agents: https://autobot.eidonix.com/p/e1513e8f-9139-4ed6-9eed-811b92098660.md

Candidate brief — PR #573 helios: tolerate omitted closing tags on complete tagged tool calls at EOS

Status note for the adjudicator: PR #573 was merged 2026-11-28 21:17 at head 701ddd4 (13 files, +1937/−104). All six upstream lenses reviewed an earlier head (09cc524, 9 files, +1423/−70); the Kani-proof commit landed afterwards. Every candidate below was re-verified against 701ddd4. The only discussion on the PR is a flare-autobot case-file bot comment — no human review. No prompt-injection content appeared in the PR text. Items below are therefore post-merge follow-ups, not merge gates.

Key findings

The mechanism is right and belongs where it is: one shared ToolDialect::parse_eos in the model-output parser layer (helios/src/output/tagged.rs:43-45), no per-model boolean flag — the exact shape the charter's "Keep the runtime small and model-agnostic … shouldn't accumulate per-model branches" and docs/design-review.md:58 ("Reject per-model boolean policy flags") forbid, and the shape that sank the predecessor PR #514 (const LENIENT_EOS_CLOSE). Leniency is gated on the request's strict field, not model identity. EosDecision (tagged.rs:224-244) cleanly separates Omit / Reject / ParseEos, and two genuine pre-existing defects are fixed as a side effect: ToolBegin counting during finish (tagged.rs:553-560) and outer_tool_pending after an already-consumed </tool_call> (tagged.rs:624-627, with outer_closed captured at tagged.rs:329) — the latter repairs a real double-close defect and is the strongest independent reason to keep the diff. No lens found a correctness defect: strict tools cannot be fabricated, undecided openers still error, and non-Eos terminations still omit.

What survives deduplication is 1 evidence/scope blocker, 4 should-fix duplication/framing items, 2 subtractive items (~700 redundant test lines of the 1423 added), and 5 mechanical nits. Six lenses produced ~25 raw findings; seven duplicate sightings of the docs item collapsed to one, and four sightings of the parse_eos-duplication item to one.


Candidate Blockers

B1. Four dialects are relaxed on assertion, not evidence — and #514 set the opposite precedent

Source: Architecture finding 1 (its only should-fix); the "unverified end-to-end" wording from Correctness was merged in.

The PR body states, as fact and with no captured generation, checkpoint or reproduction: "GLM omitting </tool_call> after </arg_value>, Qwen/MiMo omitting </function></tool_call> after </parameter>, Gemma 4 omitting <tool_call|> after }, or MiniMax XML omitting </invoke></tool_call> after a closed parameter element." The Evidence section enumerates only unit and protocol tests written for the new behaviour — those prove the code does what the author decided, not that any model emits those shapes. AGENTS.md:103-112 requires each material claim to be bound to the behaviour tested, configuration, result and limits; the charter's Bring real evidence wants a reproducible bug ("hypothetical users aren't enough to justify a change").

Weight matters here: #514 was a GLM-only version of this same change, its auto-review says "It is low value or does not align with the project charter", and lukealonso closed it "Superseded by #573". So this PR reverses a prior scope decision while adding no model evidence for any of the four dialects.

The new spec text makes the same unqualified claim:

docs/api.md:447-451
its output limit. 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.

Fix: attach one captured generation per dialect (prompt + model/checkpoint + observed unclosed output, or an issue link containing it), or narrow the change to the dialect(s) with a demonstrated defect.


Candidate Should Fix

S1. parse_eos re-implements parse_candidate verbatim in 3 of 5 dialects, and is a required trait method whose conservative default body is already written twice

Source: Conventions S2+S3, Simplicity D1, Subtractive #5, Architecture nit 2 — five lenses, one item.

helios/src/output/chatml.rs:24-32 — parse_tool (:85-93) is only parse_tool_candidate(..)?.ok_or_else(|| "incomplete JSON parameter".into()), so parse_candidate and parse_eos are the same composition with the same error string:

    fn parse(body: &str, tools: &[Value]) -> Result<Vec<(String, String)>> {
        Ok(vec![parse_tool(body, tools, WRAPPING_NEWLINES, false)?])
    }
    fn parse_candidate(body: &str, tools: &[Value]) -> Result<Option<Vec<(String, String)>>> {
        Ok(parse_tool_candidate(body, tools, WRAPPING_NEWLINES, true)?.map(|call| vec![call]))
    }
    fn parse_eos(body: &str, tools: &[Value]) -> Result<Vec<(String, String)>> {
        Ok(vec![parse_tool(body, tools, WRAPPING_NEWLINES, true)?])
    }

helios/src/output/minimax_xml.rs:200-205 — literally the same expression twice. Because parse_body(.., true) returns Ok(calls) or Err and never the empty signal, .map(Some) is unconditionally Some, which makes the trait's documented None contract (tagged.rs:39: "None means the apparent closing tag is text inside a JSON string") structurally unreachable for this dialect — and that signal is what push relies on to set in_json_string:

    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)
    }

helios/src/output/pipeline.rs:46-51 — the same error body twice, which also proves the trait default is writable:

    fn parse(_: &str, _: &[serde_json::Value]) -> Result<Vec<(String, String)>> {
        Err("tool parsing is not configured".into())
    }
    fn parse_eos(_: &str, _: &[serde_json::Value]) -> Result<Vec<(String, String)>> {
        Err("tool parsing is not configured".into())
    }

helios/src/output/tagged.rs:31-51 — parse_eos has no default, so every implementor inside or outside the crate must now write it (pub trait ToolDialect sits in pub mod tagged, re-exported under the crate's server feature at helios/src/lib.rs:20-23):

    fn parse(body: &str, tools: &[Value]) -> Result<Vec<(String, String)>>;
    /// `None` means the apparent closing tag is text inside a JSON string.
    fn parse_candidate(body: &str, tools: &[Value]) -> Result<Option<Vec<(String, String)>>> {
        Self::parse(body, tools).map(Some)
    }
    /// Parse an unclosed call body at natural end-of-sequence (`Termination::Eos`).
    /// Accepts only structurally complete, self-delimited, non-strict calls.
    fn parse_eos(body: &str, tools: &[Value]) -> Result<Vec<(String, String)>>;

Making parse_eos required is correct (defaulting it to parse would silently make every new dialect lenient, defeating the anti-fabrication intent) — the defect is that this rationale is unwritten and the bodies duplicate. Fix: have each parse_eos delegate (Self::parse_candidate(..)?.ok_or_else(..) / Self::parse(..)), keep the method required but document why there is no default at tagged.rs:43-45, and add a test for MiniMax's </tool_call>-closed-without-</invoke> streaming case so the changed non-EOS path is intent rather than accident. Counter-example done right: argument_tags.rs:25-111 — its eos flag carries checks with no streaming counterpart (name charset :36, strict :45, non-empty body :48), so it is not duplication.

S2. The "find function by name, then read strict" idiom now has four copies — and strict just became the anti-fabrication gate

Source: Conventions S1 (sole). Kept because the PR makes strict load-bearing.

helios/src/output/argument_tags.rs:40-50:

        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));
        if eos && strict {
            return Err("incomplete strict GLM tool call".into());
        }
        if eos && rest.trim().is_empty() {
            return Err("incomplete GLM tool call".into());
        }

helios/src/output/chatml.rs:109-113:

      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));

helios/src/output/gemma_call.rs:123-131 — new in this PR, refactored from find(..).and_then(get("parameters")) to keep the whole function only so it can test strict:

        let function = tools
            .iter()
            .filter_map(|tool| tool.get("function"))
            .find(|function| function.get("name").and_then(Value::as_str) == Some(name));
        if eos && function.is_some_and(|f| f["strict"].as_bool() == Some(true)) {
            return Err("incomplete strict Gemma call tool call".into());
        }
        let schema = function.and_then(|function| function.get("parameters"));

helios/src/output/minimax_xml.rs:162-171 — also new, strict now gates the unclosed-invoke branch:

            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));
            let schema = function.and_then(|tool| tool.get("parameters"));
            let (mut parameters, next, closed) = match tail.split_once(INVOKE_END) {
                Some((parameters, next)) => (parameters, next, true),
                None if allow_unclosed_invoke && !strict => (tail, "", false),
                None => return Err("unterminated XML invocation".into()),
            };

Two further variants already exist: dsml.rs:288-291 (precomputed strict names via tool.get("function")?) and recipient.rs (direct indexing tool["function"]["name"]). Four hand-written truthiness checks on the one field that now decides whether a call may be fabricated is a drift hazard (one may accept "strict": "true", one may index a function object it forgot to filter_map, one may panic on a non-function tool entry). Fix: one pub(super) fn function(tools, name) -> Option<&Value> + is_strict(Option<&Value>) -> bool in super::tagged, beside the existing shared helpers (strict_nonstring_raw, container_parameter).

S3. docs/api.md states the new rule twice, with divergent exclusion lists and an over-general subject

Source: Conventions S4, Simplicity D5, Subtractive #6, Architecture nit 3, Prose nits 1-3, Correctness nit 2 — seven sightings, one item.

First statement, docs/api.md:447-451 (quoted under B1). Second, docs/api.md:514-525:

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 at least one closed
`<arg_key>...</arg_key><arg_value>...</arg_value>` pair without `</tool_call>`,
function-tag parsers require at least one closed `<parameter=...>...</parameter>`
without `</function>` (also accepted when closed by `</tool_call>`), Gemma 4
requires a balanced `{...}` argument object without `<tool_call|>`, and MiniMax
XML requires at least one closed parameter element without `</invoke>` (also
accepted when closed by `</tool_call>`). 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.

Three defects in one item: (a) the two exclusion lists differ in membership ("unclosed strict calls" vs "strict calls missing their wire closer"; only the second mentions limits/stop sequences); (b) the second enumeration reads as exhaustive but silently omits Cancelled and ExecutionError, which also omit — tagged.rs:247-256:

    fn eos_decision(&self, cause: Termination) -> EosDecision {
        if matches!(
            cause,
            Termination::Cancelled
                | Termination::ExecutionError
                | Termination::UserStop
                | Termination::OutputLimit
        ) {
            EosDecision::Omit
        } else if !self.confirmed || self.in_json_string {
            EosDecision::Reject

(c) "tagged tool parsers" over-generalises: recipient, tml, xtml (their own envelope state machines) and DSML implement no parse_eos, and docs/api.md:511-512 names only DSML/XTML as exempt. Also "natural completion" is never defined although the code condition is exactly Termination::Eos. Fix: keep the per-dialect paragraph, reduce 447-451 to the truncation/omission fact plus a pointer, name the four dialects, define natural completion as the EOS token, and add cancellation/execution error to the exclusion clause.

S4. The leniency also fires mid-stream at the outer closer, not only "at EOS" as the title and framing say

Source: Correctness nits 1-2 + Conventions S2 consequence 1.

FunctionTags::parse_candidate (chatml.rs:27-29) and MiniMaxXml::parse_candidate (minimax_xml.rs:200-202) both pass the lenient flag, and parse_candidate is what push calls at the outer closer (tagged.rs:326, reached from select_candidate at :319). So <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". Meanwhile argument_tags.rs:106-108 and gemma_call.rs:144-146 pass false on the push path and recover only at EOS — an asymmetry that is a modelling choice, not a bug, is tested, and is documented at docs/api.md:514-525, but that the title/changelog and docs present as uniform. Fix: no code change required — state it in the title/changelog ("… at EOS and at the outer closer for function-tag and MiniMax dialects") and mark the two dialects that also recover at </tool_call>.


Candidate Subtract / Simplify

X1. ~700 of the 1423 added test lines re-assert coverage that already exists

Source: Subtractive #1 + Simplicity D2. Correctness explicitly found no fault with these tests, so the framing is "redundant", never "wrong".

(a) helios/src/server/protocol/tests.rs:2350-2664 (348 lines) — unclosed_tagged_tool_calls_at_eos_match_protocol_and_control_semantics loops 5 dialect configs × 3 protocols × 6 steps, re-proving undeclared-call handling (:407-611), parallel_tool_calls: false (:724-765), required/named tool_choice (:321, :366), and limit/stop finish reasons (:1461, :1550). Steps 5-6 (:2606-2660) assert that OutputLimit/UserStop omit an unclosed call — that is the single dialect-independent early return in EosDecision::Omit (tagged.rs:247-256), already covered at chatml.rs:886-899. (Citation erratum applied: do not cite :1550 as unclosed-call omission coverage — it is OutputLimit finish-reason mapping for an open Responses item.) The genuinely new fact is one line per dialect. Keep glm × Chat, buffered + streamed.

(b) The "non-EOS causes always omit" loop is copy-pasted four times for one shared branch, argument_tags.rs:600-614:

        // Non-EOS termination causes always omit unclosed calls, even when arguments are closed.
        for cause in [
            Termination::OutputLimit,
            Termination::UserStop,
            Termination::Cancelled,
            Termination::ExecutionError,
        ] {
            let mut parser = ArgumentTagOutput::new(config());
            parser
                .push(Input::Text(
                    "</think><tool_call>run<arg_key>text</arg_key><arg_value>ok</arg_value>",
                ))
                .unwrap();
            assert!(parser.finish(cause).unwrap().is_empty(), "{cause:?}");
        }

plus chatml.rs:1100-1106, gemma_call.rs:308-314, minimax_xml.rs:401-407. All four exercise tagged.rs:247-256, a branch this PR does not touch, and chatml.rs:886-899 already asserts Cancelled/ExecutionError/UserStop omission. Keep one instance, moved to tagged.rs where the branch lives.

(c) Every new per-dialect case list is wrapped in char_indices() and re-run at every UTF-8 split (argument_tags.rs:419, :470; chatml.rs:969, :998; gemma_call.rs:250; minimax_xml.rs:331), duplicating split-invariance tests that already exist (chatml.rs:364 — erratum applied: not :363 — and the existing for split in text.char_indices() loop at argument_tags.rs:318; the pattern is established repo-wide at dsml.rs:426, dsml.rs:631, dsml.rs:636, recipient.rs:442, xtml.rs:477 (not opened)). One recovery case per dialect per split suffices.

(d) helios/src/server/logprobs.rs:362-463 (+101) asserts content-logprob arrays, reasoning-token counting, worker-vs-local byte equality and Responses streaming — machinery this PR never touches, already covered for a closed GLM call (logprobs.rs:166-360). Its only PR-dependent assertion is the recovered arguments string, asserted at parser level (argument_tags.rs:367-505) and encoder level (protocol/tests.rs:2350+). Delete it, or drop the duplicate GLM case from the protocol matrix.

Keep: the strict-tool and partial-value assertions (chatml.rs:1024-1068, gemma_call.rs:294-306) — those do prove new behaviour.

X2. Three entry points per dialect with three names for one flag; the triplication is what keeps the test-only parse alive

Source: Conventions S2 + Subtractive #2, with a correction to the subtraction lens.

tagged.rs:26-29 (eos: bool), chatml.rs:89 (allow_unclosed_function: bool), minimax_xml.rs:147 (allow_unclosed_invoke: bool) all mean "accept the omitted wrapper at natural completion", but they are not equivalent: chatml and minimax also pass true from parse_candidate (see S4), while argument_tags and gemma pass true only from parse_eos. A reader cannot tell whether this is three deliberate per-dialect knobs or one flag spelled three ways.

Correction to the subtraction lens: parse is not production-dead. GemmaCall and PlainText have no parse_candidate impl and rely on the trait default Self::parse(body, tools).map(Some) (tagged.rs:40-42), so only the ArgumentTags/FunctionTags/MiniMaxXml parse bodies (argument_tags.rs:103-105, chatml.rs:24-26, minimax_xml.rs:197-199) exist solely to serve their own unit tests. Fix: one flag name, make the parse_candidate/parse_eos relationship explicit, and either delete those three parse bodies (moving their tests onto parse_candidate/parse_eos) or document why parse stays public.


Candidate Nits

N1 — Error strings are garbled by splicing into the generic "incomplete {} tool call" format (tagged.rs:279-285). gemma_call.rs:127-128 produces "incomplete strict Gemma call tool call" — doubled "call" and it does not say what is missing; argument_tags.rs:45-46 is grammatical but equally vague. Prefer "strict Gemma call requires <tool_call|>" / "strict GLM call requires </tool_call>".

N2 — Dead resets in TaggedTools::finish, helios/src/output/tagged.rs:339-344:

    fn finish(&mut self, cause: Termination) -> Result<Vec<Event>> {
        let decision = self.eos_decision(cause);
        let body = std::mem::take(&mut self.buffer);
        self.search_from = 0;
        self.in_json_string = false;
        self.escaped = false;

search_from is only read as an index into self.buffer and escaped only feeds the in-string scan under in_json_string; with the buffer taken and the decision already computed, neither reset has a reader. Delete them, or state in one comment that finish leaves the parser reusable (a contract ToolCallParser never states) — in_json_string's reset must be kept only on that reading.

N3 — Two "extract the one expression" duplications. (i) ToolBegin counting exists three times: new tagged.rs:555-558, pre-existing tagged.rs:610-614, and recipient.rs:273-274 — a fn begun(events: &[Event]) -> usize beside emit_calls replaces them. (ii) The name-terminator predicate is spelled twice in argument_tags.rs: :36 name.chars().any(|c| c == '<' || c == '>' || c.is_whitespace()) vs :119 text.find(|c: char| c == '<' || c == '>' || c.is_whitespace()).

N4 — The trait doc does not say who else owns EOS recovery. recipient.rs:270-272 (if matches!(self.state, State::Tool) && cause == Termination::Eos, with no strict gate and no self-delimiter check), tml.rs:374 (not opened), xtml.rs:243 (not opened) already recover unclosed calls at EOS with private logic. One sentence in the parse_eos doc (tagged.rs:43-45) plus the matching clause in docs/api.md would stop a reader treating the omission as a bug — they are not equivalent, since only the tagged dialects enforce strict and self-delimiting.

N5 — PR-description/prose mechanics (combined, one item, non-substantive). The description answers the four mandatory questions in order (AGENTS.md:72-79), the Discord: line is present (AGENTS.md:142-153), unrun checks are honestly disclosed (FLARE_*_TEST_SNAPSHOT, FLARE_TEST_TEMPLATE_DIR, live GPU serving), and the "14 passed" count checks out (10 #[test] + 4 #[tokio::test] in helios/tests/deepseek_output.rs (not opened)) — the Prose lens's earlier "evidence not reproducible" finding was withdrawn and is not reported. Remaining mechanical tweak only: the "What changed" list names the six source files plus docs/api.md but not helios/src/output/tagged/kani_proofs.rs, which the description claims as a headline deliverable.


Open questions (for the adjudicator, not verified by any lens)

  1. B1 vs. merge reality. The PR is already merged. Does an unsubstantiated four-dialect scope change warrant a follow-up demand for captured generations, or does the merged state plus the honest disclosure and the two genuine defect fixes make it acceptable? The self-delimiting and strict gates (argument_tags.rs:36-50, chatml.rs:127-129, minimax_xml.rs:168-171, gemma_call.rs:127-134) mean no fabricated call is possible even if a model never emits the relaxed shape — so the cost of the missing evidence is a dead code path, not a wrong result. That is the crux judgment call.
  2. X2's parse bodies: is ToolDialect::parse intended to remain a public, test-only entry point? A maintainer's answer decides between "should fix" and "fine as is".
  3. N2/calls bump observability: TaggedOutput::calls readers are tagged.rs:761 (newline trim) and :794 (index), both inside parse; finish runs after. I kept the calls += bump out of the fix list because the PR's own test reads it (tagged.rs:1076-1079) and Correctness showed the index is correct when the only call is emitted at finish — but "verify the bump is observable, else delete" is a fair question.

Dropped as noise (audit trail — do not re-raise)

What could not be found

No subtraction in the recovered-call rules themselves: the strict gate, the "at least one closed argument pair" requirement and the "no trailing non-whitespace" requirement are the substance of the change, and each dialect's body shape genuinely differs, so no shared helper would be shorter than the 3-5 lines per dialect. RawArguments::is_empty has no existing equivalent worth inlining. Live tokenizer/grammar behaviour of the omitted-closer path remains unevidenced by design (the checkpoint-gated suites and GPU serving were not run by the author either); verification stops at the output-parser, decoder/logprobs and protocol-encoder layers.