Explore report · NVIDIA/hyperflare-inference #514

Raw Markdown for agents: https://autobot.eidonix.com/p/f7373fd3-78d1-40f5-8543-1a6310eecba4.md

PR #514 case file — helios: allow lenient EOS close for GLM argument-tag tool calls

Repo: NVIDIA/hyperflare-inference · Author: jannerchang (association NONE) · Base main @ 2771618 · Head 732b868 · +61/−0 in 2 files · Open, ready for review, opened and last updated 2026-11-25 · no labels, no reviews, no comments, no CI on head.

Key findings

1. The change

What it does, in plain terms. GLM tool calls are written as <tool_call>NAME<arg_key>k</arg_key><arg_value>v</arg_value></tool_call>. Helios's GLM dialect (ArgumentTags, NAME = "GLM", argument_tags.rs:23-33) buffers the body until the envelope closes. When generation ends at EOS without the closer, TaggedTools::finish returns Err(format!("incomplete {} tool call", D::NAME)) — for GLM, "incomplete GLM tool call" — which aborts the response. The PR adds a trait-level switch (default off) and, when on for GLM, retries D::parse on the buffered body at EOS; if that yields a non-empty call list, it emits the normal ToolBegin/ToolArguments/ToolEnd triples and the response completes instead of erroring.

Diff, all three parts (verified at head 732b868):

  1. helios/src/output/tagged.rs:38-40 — new const LENIENT_EOS_CLOSE: bool = false; on pub trait ToolDialect, with a two-line doc comment ("When true, an unclosed tool call reaching normal EOS still attempts lenient parsing instead of aborting the whole response."). Nearby trait consts: tag constants, FUNCTION, TOOL_ENDS_REASONING (tagged.rs:31-40).
  2. helios/src/output/argument_tags.rs:29 — const LENIENT_EOS_CLOSE: bool = true; in impl ToolDialect for ArgumentTags. Every other implementor leaves the default: ChatML/Qwen FunctionTags, gemma_call, minimax_xml, pipeline PlainText; DSML, XTML and the recipient parsers are separate state machines.
  3. helios/src/output/tagged.rs:304-329 (inside fn finish, tagged.rs:293-331) — before the unconditional error at tagged.rs:330: if cause == Termination::Eos && D::LENIENT_EOS_CLOSE { let raw = std::mem::take(&mut self.buffer); if let Ok(calls) = D::parse(&raw, &self.tools) && !calls.is_empty() { return Ok(calls … ToolBegin/ToolArguments/ToolEnd with index = self.index + offset) } }, then the unchanged error line.

Test: output::argument_tags::tests::unclosed_glm_tool_call_at_eos_emits_parsed_call (argument_tags.rs:346-375) pushes </think><tool_call>run<arg_key>text</arg_key><arg_value>ok</arg_value>, calls finish(Termination::Eos) and asserts exactly one call run with {"text":"ok"}; a second half asserts <tool_call> plus whitespace (empty name) still errors.

Scope: +61/−0, no deletions, no doc/API/config/CHANGELOG/contract/protobuf change, no new dependency. The event-construction block duplicates the existing one in TaggedTools::push (tagged.rs:269-287) — ~20 lines of copied flat_map/enumerate shape.

What the lenient branch actually accepts (verified by reading ArgumentTags::parse/parse_candidate, argument_tags.rs:31-118):

Interaction with strict tools (the least obvious consequence): strict tool events are held in OutputEncoder::pending_strict_calls (server/protocol/encode.rs:496-553) and validated against the compiled TextGrammar; Encoder::finish raises incomplete strict tool call {name:?} at end of generation only if one is still pending at EOS (encode.rs:599-603). A recovered GLM call emits Begin/Arguments/End in one batch, so it is never "pending": a schema-valid recovered call now succeeds under strict: true, and a recovered-but-invalid one fails with a TextGrammar::validate/argument error instead of the incomplete-call error. Note also that the strict generation grammar requires </tool_call> (grammar/strict.rs:2280-2301), so under strict generation the model should not be able to stop early at all — the lenient path mostly matters for non-strict requests.

Description vs diff audit: nothing the description claims is missing from the diff (flag added, GLM enabled, parse-and-emit-or-fall-through, other dialects untouched, named test added). What the description omits is consequences, not code: docs not updated; strict-path failure-mode change; finish_reason change; tool_choice error disappearance; off-schema arguments; no live evidence; and that the trait gains a behavior switch enabled for exactly one model family, which touches AGENTS.md/charter's "no per-model special cases or flags" line.

2. The why

Claimed problem (PR description): in multi-turn tool calling with GLM models (e.g. GLM-5.3-Flash) the model "occasionally" emits a complete <tool_call>name<arg_key>…</arg_key><arg_value>…</arg_value> and then hits EOS without </tool_call>; TaggedTools::finish then unconditionally returns "incomplete GLM tool call", aborting the stream even though the buffered body is complete and valid.

Evidence offered: none beyond the new unit test with hand-written text — no reproduction, no captured SSE/JSON, no model version/log, no frequency, no before/after measurement. The PR does not link an issue.

How long / how widely wanted:

4. Recent activity

5. People

6. Community

7. Project fit

Charter (read_charter):

8. Claims and evidence

Claim What backs it Verdict
GLM "occasionally" emits a complete call then EOS without </tool_call> PR prose only. No frame, log, model build, frequency, or user report. The general behavior is corroborated in #67 (Qwen prose, 7/20 logprob requests) and #133's asymmetry discussion, but not for this exact GLM case Unsupported for the GLM-specific claim
Current code aborts the stream with "incomplete GLM tool call" Verified in code: tagged.rs:330 error, propagated as a response error Confirmed
New behavior only accepts a parseable, non-empty body Verified: gated on D::parse → parse_candidate completeness rules (argument_tags.rs:31-118), !calls.is_empty() at tagged.rs:307 Confirmed
Other dialects keep strict errors Verified: default false at tagged.rs:40; no other implementor overrides Confirmed
"24 passed, 0 failed" for output::argument_tags:: output::chatml:: on main 2771618 Self-reported. No CI checks on the head commit; quoted command is a filtered subset and lacks --locked versus the CI/AGENTS.md command Unverifiable from here; plausible in shape
Named tests exist Verified: unclosed_glm_tool_call_at_eos_emits_parsed_call (argument_tags.rs:347), malformed_calls_fail (argument_tags.rs:205), terminal_cause_preserves_incomplete_call_errors_and_never_fabricates_calls (chatml.rs:855) Confirmed
No regression risk elsewhere Not claimed explicitly, and not covered by the quoted run: dsml, xtml, minimax, gemma, recipient, grammar::strict suites are outside the filter. The #418 GLM strict prose tests and assert_unfinished_at_eos should be unaffected because their inputs have no complete arg/value pair — traced by reading only Partially unsupported

Tests that pin the EOS contract elsewhere and are expected to be unaffected: chatml.rs:702-723 (OutputLimit empty / Eos error for <function=lookup>, <tool_call>, <tool_call><parameter=…), chatml.rs:855-887, xtml.rs:576-596, recipient.rs:576 (not opened)/:614, grammar/strict.rs:3595-3721 with assert_unfinished_at_eos at :3343-3348. In output::argument_tags:: nothing asserts the old error for the flipped case: malformed_calls_fail (argument_tags.rs:205-218) covers unterminated and empty-name bodies, and truncation_and_structured_output_keep_protocol_semantics (argument_tags.rs:324-344) covers run<arg_key>text</arg_key> under OutputLimit only.

9. Reach

10. Process

Open questions / not found