PR #457 — Fail untyped TML model headers at EOS and align TMLv0 content-header and strict-tool grammars with TmlOutput
Open, ready for review, head aacbca1, base main (body cites merge of main at b9cac839). 4 files, +431/−7. Author brandonmmusic-max. No comments, no reviews, no labels, no CI checks on the head commit.
Key findings
- The reach of the parser change is wider than the description says. The new
TmlOutputerror is not scoped to grammar-constrained or/v1/responsestraffic: it fires for any TMLv0 request whose turn ends reasoning-only with a closed non-empty model header, and it surfaces asExecution(ExecutionError::State)→error_code() == "server_error"/ HTTP 500 (helios/src/output/tml.rs:399-401;helios/src/error.rs:174-178;helios/src/server.rs:647-668;helios/src/server/request/http.rs:526 (not opened),574-578,638). The description names only the streamingresponse.failedevent; buffered Responses and Chat Completions callers see an HTTP 500 where they previously saw HTTP 200 with reasoning-only output. (Scratchpad #8) - No documentation is updated, and the PR's own headline evidence is left as an open TODO. The PR changes no docs, yet
docs/api.mddocuments the affected TMLv0/strict-tool behavior anddocs/TODO.txt:5-8holds "Qualifystrict: truefunction tools on a TMLv0 core … Close when a served TMLv0 core passes those checks and the result is recorded" — exactly the live SM120 verification this PR reports — and the PR neither closes nor amends it. (Scratchpad #9) - A nuance the description omits: a header with a non-empty JSON body never triggers the new error, even when that body is invalid.
call_or_textsetsAnswerState::Emittedbefore validating the call body (helios/src/output/tml.rs:334-344), so a malformed tool payload emitted as text counts as "emitted" and suppresses the new failure. Consistent with the stated intent, but it means the guard only covers the header-with-no-body shape. (Scratchpad #8) - Key claims rest on evidence that cannot be checked from the repository. The live GPU numbers (0/5 → 5/5 tool calls with 178 tools,
4/5/5/5on preamble prompts,"strict": truereturning schema-conformingfunction_call,agentic_suite.py(not opened)SUITE: PASS) name no core hash, binary revision, baseline commit, command line or repetition count, andagentic_suite.py(not opened) does not exist in this repository (search_code "agentic_suite"→ no matches). The description itself says "5/5 tool calls (4/5['reasoning','message','function_call'])", an internal contradiction. (Scratchpad #11) - No CI enforcement of the tests being cited. The tokenizer snapshot tests are
#[ignore]-gated onFLARE_INKLING2_TEST_SNAPSHOT(helios/src/server/request/tml_tests.rs:247,394,442), consistent with existing repo practice, and the head commit has no CI checks at all, so the "8 passed" figure is a local-run claim. (Scratchpad #2, #11) - It rewrites a one-day-old layer.
helios/src/grammar/strict.rswas created by #418 (merged 2026-11-22 04:43); #457 editscompile_strict_tmland replaces its(answer | tools)ending. #418 had explicitly left served TMLv0 as an unrun check (its reviewer yatesdr accepted fixture-only TML coverage on 2026-11-21), which #457 now claims to have run. (Scratchpad #3) - Process gate unverified.
CONTRIBUTING.md:9-11requiresSigned-off-byon every commit anddocs/design-review.md:191-231requires aDesign-Signed-Off-By: …; design-review=<hex>trailer enforced by.githooks/commit-msg; both have blocked contributions before (#304, #418). Whether #457's commits carry them could not be determined with the available tools — an open check for a reviewer. The description does include the requiredDiscord: no username providedline (AGENTS.md:142-153). (Scratchpad #10) - Zero engagement. No comments, no reviews, no labels; the PR has not yet drawn the triage that comparable work got (#228 got
area:api,bug,priority:P1,triage:review; #418 went through two review rounds by yatesdr). (Scratchpad #2, #7, #13)
The change
Shape and size. 4 files, +431/−7: helios/src/grammar.rs, helios/src/grammar/strict.rs, helios/src/output/tml.rs, helios/src/server/request/tml_tests.rs. Three parts:
- Parser (
output/tml.rs) — a newAnswerState { Empty, HeaderWithoutContent, Emitted }onTmlOutput. A non-empty model header (model && at > 0) closing on<|end_message|>(END) or<|content_model_end_sampling|>(TURN_END) while the state is stillEmptyrecordsHeaderWithoutContent;finish()turns that into an error whencause == Termination::Eos(helios/src/output/tml.rs:376-403). Visible non-thinking content and non-empty tool-invocation bodies setEmitted. - Content-header grammar (
grammar.rs::compile_content_headers) — a factoredtool_unnamedrule<|content_invoke_tool_json|> @payload_any <|end_message|>backed by one JSON schema withenumover the registered tool names, kept beside the existing per-tooltool_{index}rules with per-toolconstschemas; and the tool-enabled ending changes from(answer | tools)to(answer ({restart} thinking* tool)* | tools). - Strict grammar (
grammar/strict.rs::compile_strict_tml) — atool_unnamedrule with(@payload_0 | … | @payload_k)over the active tools' wrapper schemas, and the non-required ending becomes(answer ({restart} thinking* tool)? | tools)whensingle_callis set,…* tool)*otherwise.
Tests added (per diff/body): output::tml unit tests nonempty_model_header_closed_without_a_content_kind_fails_at_eos, a_closed_untyped_header_allows_visible_content_and_completed_calls, empty_model_headers_other_roles_and_external_stops_keep_their_termination; grammar::tests::content_headers_grammar_allows_preamble_before_tools; a TML_unnamed case in strict_tool_wire_grammars_enforce_constraints plus strict_tml_grammar_allows_unnamed_headers_and_preamble_before_tools; and three tokenizer-gated #[ignore] tests in server/request/tml_tests.rs (a_model_frame_without_a_content_kind_reports_a_failed_response, inkling_stress_untyped_closed_header_must_surface_failure, inkling_stress_custom_grammar_preamble_then_tool). (Scratchpad #1)
The two grammars really were stricter than the parser — verified, not just claimed.
TmlOutput::call(helios/src/output/tml.rs:346-374) rejects only a present, mismatching header name (self.name.as_ref().is_some_and(|header| header != name)), so<|message_model|><|content_invoke_tool_json|>{"name":…,"args":…}parses. Before this PRcompile_content_headersrequiredself.marker(name)before<|content_invoke_tool_json|>for every tool, with no unnamed alternative (helios/src/grammar.rs:399-401before) — the grammar masked a sequence the parser accepts.- The preamble-then-tool shape likewise: TML compiled to
(answer | tools), while the Atem/XTMLcompile_recipientpath already usedwrapped_answer (ws tool)*(helios/src/grammar.rs:353). (Scratchpad #6)
Cost-motivated design detail not in the description: the unnamed rule is deliberately factored — one rule with a schema enum over tool names in grammar.rs, a payload union in strict.rs — rather than N unnamed variants, to avoid N-way Earley ambiguity across large tool sets. That choice is visible in the diff but only implied by the description's phrase "avoiding N-way Earley ambiguity". (Scratchpad #6)
What the description says that the code does not do: nothing material was found. The description's "preserving existing behavior … for turns that emit visible text or a tool call before or after an untyped header" matches the tests; the external-termination carve-out (OutputLimit, UserStop, Cancelled, ExecutionError) matches cause == Termination::Eos. The one over-statement is scope: it frames the failure as a Responses-streaming outcome (see Reach). (Scratchpad #8)
The why
The reported defect is two-fold, from a live Inkling 2 / TMLv0 serving observation relayed from outside (credited to @madarkadonk, madar on Local Inference Lab Discord):
- A malformed turn — reasoning frame, then
<|message_model|>with header text (e.g. tool name plus partial JSON) where<|content_invoke_tool_json|>was dropped, then<|end_message|>/<|content_model_end_sampling|>— was silently completed.TmlOutputdiscarded the header text and returnedOkonTermination::Eos, so/v1/responsesemittedresponse.output_item.done(reasoning)thenresponse.completed(output=[reasoning])withstatus: "completed"and no error, and agent clients treated a broken tool turn as a finished reply. - Activating any custom grammar (
start: /(?s:.+)/) or"strict": truemasked<|content_invoke_tool_json|>directly after<|message_model|>, causing models either to print raw tool JSON inside<|content_text|>or to loop in thinking frames.
The category is not new to this project: #228 (merged 2026-11-11, voipmonitor) was the same class — a structured-output grammar rejecting framing the parser itself accepted, so the model's preferred token was masked and it looped to the token limit — and it was triaged as priority:P1 / bug. #457 explicitly says its new ending matches XTML's wrapped_answer (ws tool)* framing, i.e. it follows the shape #228 settled on. (Scratchpad #6, #7)
The PR's lineage framing ("introduced in #304 and hardened in #405, with strict function tools added in #418 and Inkling 2 Mini merged in #433") is imprecise: #304 (original-el8, merged 2026-11-20) is an Inkling 2 Small NVFP4 recipe/serving PR with no helios/src files; #405 (yatesdr) is control-marker/prompt plumbing (model/prompt.rs (not opened), output/pipeline.rs (not opened), frontend/*) with no TML grammar code; #433 (nero−) is Inkling 2 Mini preparation/vision/kernels. Only #418 actually contains TML grammar code. The rest are the model-serving/packaging PRs whose traffic hits the parser. (Scratchpad #5)
Related work
- #418 — Add strict function-tool schemas for DSML, Qwen, GLM and TML parsers (merged 2026-11-22, jcartu, +6048/−128, 16 files). Created
helios/src/grammar/strict.rs(+4504) and wired"strict": true. #457 rebases onto it (d75bc3a8"Merge main (b9cac839)") and rewrites the TML ending line it wrote. #418 also restricted active-strict TMLv0 requests to declared tool names even undertool_choice: auto— #457 keeps that restriction in both new unnamed rules. #418 left served TMLv0 as an unrun check tracked indocs/TODO.txt; reviewer yatesdr accepted fixture-only TML coverage on 2026-11-21 ("TML: fixtures are enough"). #457 now claims live served verification, i.e. it supplies that deferred check. (Scratchpad #3) - #228 — XTML message closure (merged,
priority:P1). The precedent for the defect class and the grammar shape reused here; shareshelios/src/grammar.rs. (Scratchpad #7) - #405 — Treat declared markers as controls (merged, yatesdr). Listed by the body as lineage and as a referring item, but touches none of #457's four files; the connection is that #457's tests use
tml::CONTROL_MARKERSin the style #405 established (dsml::CONTROL_MARKERS). (Scratchpad #4) - #191 — the earlier unmerged TML parser work (open draft, YouNeedCryDear, since 2026-11-04). Added
helios/src/output/tml.rs(+476),helios/src/server/request/tml_tests.rs(+194) and the TML parser kinds; flagged for merge conflicts by original-el8 on 2026-11-05 and 2026-11-08 and never merged. #457's base already containstml.rs(it landed through Luke Alonso's8628b7c5, 2026-11-14), so #191 overlaps 3 of #457's files as an older, effectively superseded attempt at the same path. (Scratchpad #12) - #458 (open) and #468 (closed), same author. #458 is the companion "Restore Responses SSE sequence_number when Encoder::apply or finish fails" fix, from the same incident; #468 said it "benefits from the companion Helios TML output-parsing and Responses SSE error-sequence fixes in #457 and #458" and was closed only because its seven files moved to
local-inference-lab/hyperflare-recipes, not because the need disappeared. So #457 is one of three PRs against a single reported incident. (Scratchpad #13) - #461 (open, jcartu) — strict-tool documentation/numeric-range PR listed via a shared file; different subject, untouched by #457. #94/#167 appear via shared
grammar.rsbut concern reasoning-delimiter counting and reasoning budget. (Scratchpad #15)
Recent activity
helios/src/output/tml.rson main has only two commits:dc0d40e0(2026-11-19, Luke Alonso, HTTP ingress/frontend bounds/crate boundaries) and8628b7c5(2026-11-14, Luke Alonso, "Prepare Inkling 2 Small NVFP4 for native TP4 serving") — i.e. the TML output parser was introduced by Luke Alonso's work, not by the still-open #191.helios/src/grammar.rs: last substantive change0b09434d(#418, 2026-11-22), before that8628b7c5(Luke Alonso),f76b517f(#228), and Luke Alonso's late-October recipient-frame series.- Area ownership over the last 180 days on
helios/src: Luke Alonso (204 commits), Martin Vit (45), yatesdr (43). - No commit on main since
b9cac83touches any of #457's four files, so no rebase conflict has appeared yet; #457 already absorbed #418 via its merge commit, which is the one real ordering dependency in this area. (Scratchpad #12)
People
- Author, brandonmmusic-max (CONTRIBUTOR). Last 180 days: 2 merged (#162 "Drop reasoning close delimiter tokens from visible content" — the closest precedent that this author has shipped Helios output-parsing behavior, touching
helios/src/output/tagged.rs(not opened),pipeline.rs(not opened) andhelios/model-contract.md; #154 warmup mappings), 3 closed (#468, #215, #163), 4 open (#480, #475, #458, #150). Not one of the charter's named priority contributors (@voipmonitor, @original-el8, @lukealonso). - @madarkadonk /
madar(external, Local Inference Lab Discord) — reported the underlying incident and is credited with the initial untyped-header patch, the captured malformed terminal-header token sequence and both TMLv0 stress tests. Both #457 and #458 trace to him. - yatesdr (COLLABORATOR) — the most likely reviewer by precedent: reviewed #405, #418, #433, #461 in these files, and is the gatekeeper who demanded harness evidence and DCO sign-off in #418/#304.
- jcartu — authored the strict.rs layer #457 edits; reviewed #433.
- Luke Alonso — dominant author of the recipient/grammar machinery the change extends.
- Nobody has engaged with #457 yet. (Scratchpad #13)
Community
Nothing found. pr_comments returns "No comments."; no reviews, no labels, no reactions are recorded, and the PR is 1–2 days old (opened 2026-11-22, last updated 2026-11-22). The only interest traceable is indirect: the outside reporter's Discord report, and the author's own three-PR bundle (#457/#458/#468). (Scratchpad #2, #13)
Project fit
Lines up:
- "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)" (
AGENTS.md:165-166) — the change stops discarding a malformed turn and instead errors, and the grammar fix removes the masking rather than compensating for it. - "Keep the runtime small and model-agnostic … shouldn't accumulate per-model branches (#267, #334)" — no model or recipe identity is branched on; the change keys only on TMLv0 framing tokens.
- The "respect the OpenAI/Anthropic documented subset" goal — this is Responses/Chat tool-call correctness.
- Non-goals untouched: no hardware, backend, recipe, alias or model-format expansion here.
Where it may not line up:
- The charter asks for the smallest footprint in shared code and for changes at the right layer; this puts a new hard failure (HTTP 500) into the shared TMLv0 output parser for every TMLv0 request, a behavior change beyond the reported malformed case (see Reach) — worth an explicit decision, not just a bug-fix framing.
- Documentation:
AGENTS.md:230requires readingdocs/api.mdfor API behavior changes,docs/design-review.mdasks that user-visible behavior changes be documented, anddocs/api.mdlacks any statement about the new EOS failure mode or the newly accepted unnamed-header/preamble framings.docs/api.md:585-602covers TMLv0 strict tools ("With an active strict tool, TMLv0 recognizes only declared tool names"), which remains true but is now incomplete about unnamed headers. (Scratchpad #9, #14)
Claims and evidence
| Claim | Evidence offered | What can be verified |
|---|---|---|
Malformed turns now fail instead of completing with output=[reasoning] (streamed response.failed, server_error) |
Narrative + unit tests | Verified in code: Err from finish → Error::Execution(State) → server_error/HTTP 500; streamed path emits response.failed, buffered path returns HTTP 500 (output/tml.rs:399-401, error.rs:174-178, server.rs:647-668, http.rs:526,574-578,638). Also applies to unconstrained TMLv0 requests. |
| Grammars now accept unnamed headers and preamble-then-tool | Diff + tests | Verified in code that the prior grammars were stricter than TmlOutput and that the new rules admit both shapes; the grammar tests are ordinary (non-ignored) unit tests. |
| 124 unit tests passed across six modules | Prose only | Not reproducible from the repo state; counts are plausible but unverified. |
| 8 real-tokenizer snapshot tests passed | Prose only, with an env-gated #[ignore] suite |
Test names exist and are #[ignore]-gated on FLARE_INKLING2_TEST_SNAPSHOT (tml_tests.rs:247,394,442); CI cannot enforce them and the head commit has no checks. |
Live SM120: 0/5 before, 5/5 after on 178 tools; 5/5 (4/5) on preamble prompts; strict get_weather returns schema-conforming function_call; agentic_suite.py (not opened) SUITE: PASS |
Prose only | Not verifiable from the repo. No core hash, binary revision, baseline commit, command line, repetition count or spread; agentic_suite.py (not opened) is not in this repository. The 5/5 (4/5 …) phrasing is self-contradictory. |
| Non-TMLv0 families only grammar-tested | Disclosed limitation | Honest and consistent with the diff (no DSML/Qwen/GLM/XTML test changes beyond the shared TML_unnamed case). |
TmlOutput still ignores non-model role frames |
Stated | Consistent with the diff. |
(Scratchpad #8, #11)
Reach
- Users/operators: every TMLv0 serving deployment, including plain unconstrained Chat Completions and Responses calls — a reasoning-only terminal turn that used to return 200 now returns HTTP 500 /
response.failed. Agent clients that tolerated the malformed completion will now see hard errors; that is the intent, but it is a client-visible compatibility change beyond grammar users. (Scratchpad #8) - Configuration/defaults: none changed; grammars are compiled per request, no new flags or defaults. Dependencies/cores: none changed; grammar and parser live in Helios, so existing exported cores keep working with no re-export (consistent with
docs/api.md:626-630and the #228 precedent).helios/model-contract.mdis untouched. - Documentation:
docs/api.mdanddocs/TODO.txtare untouched (see Project fit). - Other parsers: no behavior change to DSML/Qwen/GLM/XTML, whose tests the author says cover them (grammar::tests, grammar::strict::tests) but which were not exercised live.
Process
- Opened 2026-11-22 by brandonmmusic-max; state open, ready for review (not draft); last updated 2026-11-22; head
aacbca1; basemain; no labels; no reviews; no CI checks on the head commit. - Branch history read:
aacbca18("helios/grammar: allow unnamed tool headers and preamble-then-tool in strict TMLv0 grammars"),d75bc3a8("Merge main (b9cac839) …"),9b2f2f6a,76c50158. - Required-but-unverified: per-commit
Signed-off-by(CONTRIBUTING.md:9-11) and theDesign-Signed-Off-By: …; design-review=<hex>trailer (docs/design-review.md:191-231, hook at:210-231). Both have been enforced in practice — #418's reviewer told jcartu "Contributor DCO sign-off is still pending before I push the revised commits" (2026-11-21), and #304 was blocked on missing sign-off and a missing design-review hash (2026-11-18). Whether #457's four commits carry them could not be read with the available tooling; treat as an open check for a reviewer, not a finding. The description does carry the requiredDiscord: no username providedline (AGENTS.md:142-153). (Scratchpad #10) - Age: ~2 days at the time of this research; no maintainer touch yet.
Open questions and what could not be found
- Do #457's commits carry
Signed-off-byand theDesign-Signed-Off-Bydesign-review trailer? Not determinable with the available tools; the repo enforces both strictly. - Is the broadened HTTP 500 reach intended and accepted? The description frames the failure as a Responses-streaming fix; nothing in it addresses unconstrained TMLv0 clients, or whether reasoning-only completions of that shape are frequent enough to break existing users.
- Which core/binary was served in the live checks, and where is
agentic_suite.py(not opened)? Neither is recoverable from the repository; the "before" baseline commit is also unnamed. This is the same evidentiary standard yatesdr imposed in #418. - Why is
docs/TODO.txt's strict-TMLv0 qualification item left open if the PR reports the qualifying run? - What is the relationship to #191? #457 builds on TML code that landed on main through Luke Alonso's
8628b7c5, while #191 (open draft since 2026-11-04) is an earlier unmerged attempt at the same files; whether #191 is intended to be abandoned was not found. - How does this interact with the still-open #458 (Responses SSE
sequence_numberon encoder failure), which addresses the same incident's error path? Neither references the other's review status.