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
- It changes documented, deliberately chosen behavior without touching the docs. The contract in
docs/api.md:441-444("recognized but incomplete calls at natural completion are errors") anddocs/api.md:501-502("A tag still undecided when generation ends is parsed as an incomplete call") describes exactly what this PR stops doing for GLM, and the PR edits no documentation. Per #133's thread the asymmetry was introduced on purpose (99cfcd5be, pinned byoutput::xtml::tests::output_limits_allow_incomplete_tools_but_eos_rejects_them, xtml.rs:576-596) and changing it is "a maintainer policy decision that would edit docs/api.md, not a defect fix". - It partially reverses a rule #67 introduced and that #418 re-tightened three days earlier. #67 (merged, mark-yong) created the undecided-tag machinery and explicitly kept "a truncated call keeps failing at EOS"; #418 (merged 2026-11-22, jcartu) deliberately made GLM EOS tails reject in strict prose. #514 adds an EOS-recovery path into the same dialect — adjacent, not obviously contradictory, but it is new leniency layered on fresh strictness (see Related work).
- The evidence is a hand-written unit test only. No captured GLM stream, no frame, no frequency ("occasionally"), no before/after count, no model/log/loglevel, against a charter line that bug fixes "need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)". Comparable GLM/parser PRs (#67, #133, #418) brought captured streams or measured frequencies.
- The claimed verification cannot be checked here. "24 passed, 0 failed on main (2771618)" is self-reported; the head commit has no CI checks, and the quoted command is a two-module filter without
--locked, whereas CI (.github/workflows/native-serving.yml(not opened)) and AGENTS.md:317 run the full--lockedsuite. The named tests do exist (argument_tags.rs:347, argument_tags.rs:205, chatml.rs:855) and the chatml one still passes by construction because FunctionTags keeps the flag false. - The description omits user-visible consequences beyond "GLM now succeeds". For
strict: trueGLM tools the failure mode moves fromincomplete strict tool call … at end of generationto either success or aTextGrammar::validateerror, because recovered events arrive complete rather than sitting inOutputEncoder::pending_strict_calls(encode.rs:496-553, 599-603); the turn'sfinish_reasonbecomestool_calls(encode.rs:622-628); andtool_choice: required/named"not satisfied" errors (encode.rs:617-621) disappear for recovered calls. Arguments may not match declared schemas, because #179 deliberately retains off-schema GLM values. - Nothing pins the old behavior in a GLM test.
output::argument_tags::contains no test asserting "incomplete GLM tool call" for a body complete up to the last</arg_value>— the case this PR flips — so the PR's own new test is the only coverage of that boundary in either direction. - No engagement at all: 0 comments, 0 reviews, 0 labels, no triage, author is a new outside contributor with no merged PRs (third open PR), and the parser area is otherwise driven by mark-yong, jcartu, yatesdr, voipmonitor and triaged by original-el8.
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):
helios/src/output/tagged.rs:38-40— newconst LENIENT_EOS_CLOSE: bool = false;onpub 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).helios/src/output/argument_tags.rs:29—const LENIENT_EOS_CLOSE: bool = true;inimpl ToolDialect for ArgumentTags. Every other implementor leaves the default: ChatML/QwenFunctionTags,gemma_call,minimax_xml, pipelinePlainText; DSML, XTML and the recipient parsers are separate state machines.helios/src/output/tagged.rs:304-329(insidefn 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):
- It is gated on
D::parse, i.e. on the same completeness rules as a closed call:parse_candidatetrims, requires a non-empty name before the first<arg_key>, requires every key closed and followed by<arg_value>, and requires each value terminated by</arg_value>; it returnsOk(None)for a JSON-container argument still inside a string (thenparseyields "incomplete JSON argument"). So an unterminated final<arg_value>or<arg_key>still errors → falls through to "incomplete GLM tool call". Only a body complete up to the last</arg_value>recovers — a strict reading of "the model omitted only the closer". - Type mismatches are not checked:
parameter_value(tagged.rs:937-943) retains invalid values, so a recovered call can carry arguments that do not match declared tool schemas — the #179 behavior, now reachable at EOS. - The branch can only fire while the parser is in
Mode::Tool, i.e. after the<tool_call>opener was consumed.TaggedOutput::finish(tagged.rs:513-540) clears pending delimiters, issuespush(Input::Text(""))first (which forces an undecided opener to be treated as a call, tagged.rs:712-720), and only then dispatches to the tool parser'sfinish. So the recovery covers "opener consumed, body complete, closer missing" and also a bare trailing name, but never a body whose calls were already published. Termination::OutputLimit,UserStop,Cancelled,ExecutionErrorare excluded by the earlier guard (tagged.rs:294-303), which returnsOk(vec![])and clears the buffer. The OutputLimit/EOS asymmetry that #102 and the xtml test pin stays intact.std::mem::takeat tagged.rs:305 drops the buffered body even when the lenient parse fails; invisible externally (the error aborts the response) and the 1 MiB parser bound (tagged.rs:228-230) still applies.
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:
- No open issue asks for lenient EOS close. Searches for "unclosed tool call", "unterminated closing tag", "lenient parse tool call" return only this PR.
- The closest prior reports: #67 (merged 2026-10-25, mark-yong) records that an undecided opener at finish "is still parsed as a call, so a truncated call keeps failing at EOS" — an explicit statement that this is intended — and separately notes Qwen3.8 Flash sometimes stopping where it would have written
</tool_call>(7 of 20 logprob requests), the same "model stops before the closer" behavior, there treated as prose. - #133 (closed, eduffd, 2026-10-28) named the asymmetry directly: an open
<tool_call>at natural EOS errors withincomplete GLM tool call, while the same open call at max_tokens is silently dropped withfinish_reason=length(tagged.rs:251-263 at that revision). Maintainer reply (original-el8, 2026-11-05) in #133: introduced deliberately in99cfcd5be, pinned byoutput_limits_allow_incomplete_tools_but_eos_rejects_them(xtml.rs:576-596) and restated in #67; changing it is "a maintainer policy decision that would edit docs/api.md, not a defect fix". - So the underlying annoyance is real and previously surfaced (#67, #133), but the specific remedy has never been requested in the tracker, and the recorded maintainer position was that a change of this kind is policy + docs.
3. Related work
- #418 (merged 2026-11-22, jcartu, +6048/−128) "Add strict function-tool schemas for DSML, Qwen, GLM and TML parsers" — the same two files, merged three days before this PR. It added, per its description, rejection of trailing unresolved
<tool_call>, bare tool names and proper prefixes of<arg_key>/</tool_call>at EOS in GLM strict prose; itsglm_prose_may_mention_the_tool_call_tagtest (grammar/strict.rs:3595-3721) asserts that accepting undecided GLM<tool_call>tails at EOS breaks it, viaassert_unfinished_at_eos(grammar/strict.rs:3343-3348). Those negative cases have no complete<arg_value>pair, so #514's gate should leave them alone (traced by reading, not run) — but the direction of travel is opposite: #418 tightened GLM EOS, #514 loosens it for the complete-body case. #514 stacks on #418 (it was written against a main that includes it). - #67 (merged 2026-10-26, mark-yong) "Keep prose tool-tag mentions in function-tag and GLM output as text" — introduced
ToolDialect::starts_call, the default-deny/undecided rule, and the EOS error for truncated calls. #514 reverses the EOS half for GLM only; the prose half (mentions stay text) is untouched. - #179 (merged 2026-11-11, mark-yong, commit 9d1e0137) "Retain GLM tool arguments that do not match their declared type", closing #39 — makes GLM argument typing permissive, so the calls #514 recovers can be off-schema.
- #405 (merged, yatesdr) "Treat declared markers as controls…" — last-but-one touch to argument_tags.rs before #418; unrelated to EOS.
- #59 (open, aarongiuffre, opened 2026-10-23, updated 2026-11-25) "Fix GLM tool-call argument tag parsing" — the only other open PR on the same two files: array coercion plus better diagnostics. Already conflicted on tagged.rs per original-el8 (2026-11-13); an Autobot auto-review on 2026-11-25 stopped it as "already fixed another way". #514 does not supersede its coercion goal; if both land, they collide in
ArgumentTagsparsing and the finish path. - #228 (merged, voipmonitor) "Allow XTML message closure after structured answers" — the nearest precedent for accepting a closing envelope the model failed to write, but implemented as an explicit
OutputEnvelope.message_closegrammar permission with docs, not post-hoc recovery. #359 (merged) "Retain DeepSeek tool values that are not valid JSON" is a similar leniency precedent that came with tests and doc lines. - #102 (merged, mark-yong) and the xtml test
output_limits_allow_incomplete_tools_but_eos_rejects_them(xtml.rs:576-596) pin the OutputLimit-vs-EOS asymmetry; #514 keeps it (EOS-only branch). - Author's other open PRs: #513 (2026-11-25) "suppress prompt-only special tokens from output and stop matching" — targets the
[gMASK]leak from #133; #397 (2026-11-19) kernel-node attributes. #514 is the third open PR, none merged. #513 and #514 both come out of the same GLM-5.3 serving observations as #133.
4. Recent activity
- Commits touching
helios/src/output/argument_tags.rs, newest first: 732b8687 (this PR, 2026-11-25), 0b09434d (#418, 2026-11-22), a2bf7860 (#405, 2026-11-20), 9d1e0137 (#179, 2026-11-11), 28f0833b (licensing, 2026-10-30), a5b6ed26 (#67, 2026-10-26), 905735a5, 2a4fcb9f, bcd6b249. The GLM parser changed four times in the six weeks before this PR, twice within the last week — this is a fast-moving area, and #514 rides directly on #418. - Compaction risk is currently zero in this file, but an in-flight #59 is already conflicted on tagged.rs; a PR that reverses a rule three days after a large strict-tools PR lands is likely to need a maintainer decision rather than a routine merge.
helios/src/output/tagged.rsin the last 180 days was touched by #94, #162, #167, #228, #179, #67, #405, #418 — i.e. the shared finish path is where all the recent parser-policy PRs converge.- No commits on
mainsince the branch point (2771618) touch either changed file; newest main commit is 27716185 (Luke Alonso, 2026-11-24, RebuildManifest deprecation). Other recent helios/src work is unrelated to parsing (KV plane #473, Engram gathers #470, prefill pricing #426, tokenization #424, row-sharded prefill #499, worker telemetry #507, packed round durations #510, plus the author's own #397 area).
5. People
- Author: jannerchang — GitHub association with the repository NONE; in the last 180 days 0 merged and 0 closed PRs, 3 open (#397, #513, #514). No issues, comments or reviews in the local copy. No Discord handle or AI-assistance disclosure in the PR (both are common in this area: #67 "Written with AI assistance", #418 an AI disclosure). Signed-off-by not verified here; other PRs in this repo required
Signed-off-byon every commit (#418 discussions). - Who usually works these areas: helios/src overall in the last 180 days is Luke Alonso (207 commits), Martin Vit (45), yatesdr (43). The output-parser policy specifically belongs to mark-yong (#67, #179, #102, #94, #162 — the author of the EOS/mention semantics this PR changes), jcartu (#418), yatesdr (maintainer, #405), voipmonitor (#228), with original-el8 doing the triage reviews that recorded the deliberate-policy position in #133.
- Who has engaged so far: nobody. No assignee, no reviewer requested, no maintainer comment. Priority contributors per charter (@voipmonitor, @original-el8, @lukealonso) have not weighed in; jannerchang is not among them.
6. Community
- Zero comments, zero reviews, zero inline review comments, no reactions, no labels, no triage. Opened and last updated the same day (2026-11-25), so there has been little time; contrast #59 (labels
area:api,model:glm-5.3,triage:verify-for-closure, maintainer comments) and #418 (several review rounds). - No cross-references: the PR mentions no issue and is not referenced by any tracked item in the local copy.
7. Project fit
Charter (read_charter):
- Lines up: Flare is "built for long conversations, coding agents, and heavy tool use"; "Serve the documented Chat Completions, Completions, Responses and Messages APIs". A stream abort on a recoverable GLM call is exactly the agentic-loop failure class the project says it prioritizes.
- Tension — evidence: "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)". This change converts a rejection into an acceptance with no root-cause evidence for why the model stops before
</tool_call>(no sampling/logprob trace, no frequency). The PR frames it as a bug fix; the recorded maintainer framing (#133) is a policy decision. - Tension — model-agnosticism: "No per-model special cases or flags" / "Keep the runtime small and model-agnostic … shouldn't accumulate per-model branches". The mechanism is a typed dialect constant (AGENTS.md:362-364 endorses typed dialect identifiers for tool parsers), but the behavior switch is enabled for exactly one model family.
- Tension — docs: AGENTS.md:230 requires reading docs/api.md for API-behavior changes and the repo treats undocumented user-visible behavior changes as "should fix" (cf. the review of #457). docs/api.md:441-444 and :501-502 stay as they are.
- Precedent that aligns with leniency done properly: #228 (XTML closure) made the accepted language explicit in the grammar and documented it, with native replay evidence; #359 did the same for DeepSeek values.
- No owner-approval gate applies (no new model recipe or graph op).
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
- Who is affected: anyone serving a GLM recipe that maps to
ToolParserKind::GlmArgumentTags(contract enum value 2, helios/src/model/contract.rs:66 (not opened); pipeline mapping helios/src/output/pipeline.rs:86-88; syntax declared in helios/tests/support/contracts/glm53.json (not opened)) — GLM-5.3-Flash and other GLM-5.3 recipes. - Who is not: Qwen/ChatML/MiMo/Step/Nemotron-H (
FunctionTags), DeepSeek DSML, XTML, MiniMax, Gemma, Atem/TML recipient parsers, plain text — all keep the strict EOS error. - Configuration/defaults: none. No request field, CLI flag, contract field or default; it is compiled in per dialect and cannot be opted out of by an operator. Existing packages/cores keep working (a Flare rebuild picks it up, as with #67/#418).
- Client-visible changes for GLM:
- a turn that previously produced an SSE error / HTTP failure (no
finish_reason, no[DONE]— the behavior traced in #133) can now complete withfinish_reason: "tool_calls"(encode.rs:622-628 setstool_callswhen cause != UserStop and outputs contain tools) and delivered arguments; tool_choice: required/ named-tool requests that previously failed with "required tool choice was not satisfied" (encode.rs:617-621) now succeed when the recovered call matches;- recovered arguments may not match declared JSON schemas (#179 semantics), and are what the client will feed back in the next turn;
- under
strict: true, success or a validation-error message replaces the incomplete-call error.
- a turn that previously produced an SSE error / HTTP failure (no
- Documentation/deployment:
docs/api.md(441-444, 501-502) anddocs/TODO.txtunchanged and now partly inaccurate for GLM; no migration, no dependency, no GPU/kernel impact, no performance or memory claim beyond the existing 1 MiB parser bound. - Operators/observability: error-rate dashboards for GLM tool calls will see "incomplete GLM tool call" counts fall and
tool_callsfinish reasons rise; there is no metric distinguishing recovered calls from properly closed ones.
10. Process
- Open, marked ready for review, single commit (732b8687) from a fork; base main @ 2771618; +61/−0 in 2 files.
- No labels (no
area:api, nomodel:glm-5.3, no triage label — compare #59), no reviewer, no review, no comment, no CI checks on the head (fork PRs typically sit at action_required; #67 reported the same). - Age: opened and last updated 2026-11-25, i.e. under one day at the time of this case file; no maintainer response yet, so "unreviewed" here says nothing about acceptance.
- No Signed-off-by verification and no AI-assistance disclosure recorded in the PR body.
Open questions / not found
- Root cause: why does GLM-5.3-Flash stop before
</tool_call>? No trace, logprob, sampling-config or frequency evidence anywhere in the PR; nobody has reported it in an issue. - Which behavior is wanted: the maintainer position on record (#133) is that this asymmetry is policy and would need a docs/api.md change; whether that position still holds after #418 has not been tested — no maintainer has commented on #514.
- Is the new leniency reachable under strict generation? The strict wire grammar requires
</tool_call>(grammar/strict.rs:2280-2301), so the recovery mainly affects non-strict requests; the PR does not say which mode it targets. - Interaction with #418's strict prose tests and with #59's parsing rewrite was traced by reading, not run; no full-suite CI exists for this head.
- Doc update: no statement that docs/api.md will be updated, and none made.
- Not found: any issue requesting lenient EOS close; any label/triage; any maintainer or community engagement; any reaction/upvote signal; any performance measurement (none claimed).