Review — PR #457 "Fail untyped TML model headers at EOS and align TMLv0 content-header and strict-tool grammars with TmlOutput"
Cases file: https://autobot.eidonix.com/api/v1/cases/55324286-e803-428d-8c71-9250e0eda2d6.html (intake report: https://autobot.eidonix.com/p/bb7bbb07-391b-43fd-a3b9-6d4daa1e5b3c.html)
- Author: brandonmmusic-max; branch
tml-untyped-headers-and-content-grammar→main; headaacbca1(aacbca18206cd37d727e35f5ed49bdfa0c379a8e), baseb9cac839. - Size +431 −7, 4 files, no documentation touched:
helios/src/grammar.rs(+81/−2),helios/src/grammar/strict.rs(+134/−2),helios/src/output/tml.rs(+91/−3),helios/src/server/request/tml_tests.rs(+125/−0). - The only discussion comment is the case-file notice; there are no reviews, no inline comments and no contributor replies, so nothing in the thread needs answering and no finding below is contested.
- Related PRs cited by the description: #304, #405, #418, #433 (merged), #458 (open), #468 (closed — where the
TML-d24-varloop-researchalias went, moved tolocal-inference-lab/hyperflare-recipes).
Key findings
- The description says the change fails "malformed TMLv0 turns … without any visible text or tool call", but the guard keys on the header shape. Turns that close a typed empty body after a bad header —
[MODEL,"bash",TEXT,END],[MODEL,JSON_CALL,END], and reasoning-then-empty-body — still finishOkwithoutput=[reasoning],status: "completed"(helios/src/output/tml.rs:282-288,:207-209,:335-337,:399-401). The symptom the PR is fixing therefore survives in adjacent shapes. - The description's central grammar argument is applied to only one of the two grammar paths.
compile_content_headersfactors the unnamed header through one schema whosenameis anenumof tool names, "avoiding N-way Earley ambiguity across large tool sets" (grammar.rs:381-391);compile_strict_tmlwrites exactly that alternation,(@payload_0 | … | @payload_k)over per-tool wrapper schemas (strict.rs:1599-1603). Largest test coverage is two tools, live strict evidence is one, and the 178-tool measurement is non-strict only. - Grammar and parser still diverge, in the opposite direction. Both new endings require a
<|message_model|>restart between a visible answer and a following tool call (grammar.rs:405,strict.rs:1616-1618);TmlOutputopens a call body straight after<|end_message|>(tml.rs:250-258). The PR's headline is alignment withTmlOutput. - Three user-visible TMLv0 behaviour changes ship with no
docs/api.mdupdate, anddocs/api.mdis the contract for exactly this surface. - The new evidence is not reproducible from this branch: a checkpoint the repository rejects, a placeholder env var, and an unpathed suite for the round-trip numbers.
- A third of the new test code re-proves its own assertions: one ignored snapshot test replays another byte-for-byte, and one default-path unit test compares the parser with itself.
- Everything else in all five lenses passes: correct layer, no per-model branch or switch, no weakened guarantee, no unmeasured performance claim, and the grammar versions are supersets of the old language.
Blockers
None. The three production changes are small, parser-local and in the correct layer; each grammar change is a superset of the old language for tool-enabled TMLv0. The docs/api.md gap (S1) is required by AGENTS.md:225 and should land in this PR, but it is documentation, not a code blocker.
Checked and clean by every lens:
- No per-model branch, capability boolean, flag or environment switch. The new
AnswerState(tml.rs:78-83,:104, set at:219,:287,:338, read at:399) is parser state on oneTmlOutputinstance, i.e. per served turn, not serialized, so prefix-cache reuse cannot resurrect it. Grammar selection still keys on the prepared parser kind (output/pipeline.rs:183-190(not opened) →grammar.rs:241-246). AGENTS.md:171-176 anddocs/design-review.md:31-49(not opened) satisfied. - No weakened constraint. At most one
@answerframe;single_callstill caps at one tool (strict.rs:1606-1616, asserted at:4633-4634); unregistered tools still rejected through theenumatgrammar.rs:383and through the per-tool wrappers; named-header mismatches and duplicate@answerstill rejected (grammar.rs:1982). The change adds rejection where output was previously silently accepted. - Terminations preserved.
OutputLimit,UserStop,Cancelled,ExecutionErrorare exempt: the check gates oncause == Termination::Eosand returns early for cancelled/execution errors (tml.rs:378-383,:399), pinned by the new unit test. Non-model role frames stay exempt (:282-286gates onmodel). - Layer and scope. The failure is raised in the TML parser, not the HTTP or encoder layer; the HTTP layer only observes the existing error path (
server/output.rs:332-341→protocol/encode.rs:760Encoder::failure).compile_recipient's(answer | tools)(grammar.rs:354) serves the ATEM/recipient parser, so leaving it untouched is correct scope. - No artifact churn. No checkpoint, recipe, exported core, grammar cache or on-disk format touched; no serialization or wire change; four Rust files, one test-only.
Should Fix
S1 — docs/api.md states none of the three user-visible TMLv0 behaviour changes [Architecture, Prose]
Finding. docs/api.md:585-602 is the TMLv0 strict-tool contract and says nothing about an unnamed header (<|message_model|><|content_invoke_tool_json|>), nothing about a visible text preamble followed by tool calls, and nothing about the new EOS failure; search_code over docs/ for content_invoke_tool_json, unnamed, message_model, preamble returns no match. The nearest sentence, docs/api.md:443-444 ("recognized but incomplete calls at natural completion are errors"), does not describe the new condition. The PR changes four files, none of them documentation, and does not flag the gap under "Unrun Checks and Limitations".
Request. Add one paragraph near :585-602 covering (a) unnamed versus named TMLv0 tool headers, (b) a text preamble followed by tool calls, and (c) a non-empty model header closed by <|end_message|>/<|content_model_end_sampling|> with no content-kind token and no answer now fails the turn at EOS as response.failed / HTTP 500 server_error; and update :443-444 to separate the two conditions.
Why. AGENTS.md:225 names docs/api.md for API behaviour changes, and AGENTS.md:47-55 requires documents to state present behaviour, so this cannot be deferred to docs/TODO.txt. The same section already documents comparable failure modes (:535-536, :543-545, :621-625), so silence here is an omission rather than a style choice.
S2 — the EOS guard keys on the header shape, not on the defect's symptom, so adjacent shapes still complete silently [Correctness]
Finding. HeaderWithoutContent is recorded only when a non-empty model header closes on <|end_message|>/<|content_model_end_sampling|> while answer == Empty (tml.rs:282-288), and Emitted is set only for non-empty bodies (emit returns at tml.rs:207-209; call_or_text returns at :335-337). Traced consequences, all still Ok with output=[reasoning], status: "completed":
[MODEL,"bash",TEXT,END]— the header closes onTEXT,markeris neitherENDnorTURN_END, so the condition at:282-288never fires; the visible body is empty, soemitearly-returns;answer == Emptyatfinish.[MODEL,JSON_CALL,END]— the header closes onJSON_CALLwithat == 0, soat > 0fails; the call body is empty, socall_or_text("")early-returns.[MODEL,THINK,"plan",END,MODEL,"bash",TEXT,END]and…[MODEL,JSON_CALL,END]— the reasoning-only turn the PR is about, still silent once any content-kind token is present.
tml.rs:652-653 shows the reasoning-only turn ending at TURN_END is deliberately still Ok, so an empty answer frame is currently intentional — but that intent is unstated and contradicts the description's wording.
Request. Either widen the check to "a model frame was opened and no answer or call was emitted at EOS" (still excluding external terminations and empty headers), or state the boundary explicitly in the S1 paragraph and add the three sequences above as tests that pin the intended outcome.
Why. The description claims the guard covers turns with "no visible text or tool call"; these sequences satisfy that reading yet remain silent, so a reviewer cannot tell an intentional boundary from a hole. If the check is later widened, note that finish() computes events from drain() at tml.rs:387 and then returns Err at :399-401, dropping them — harmless today only because nothing can emit without setting Emitted, and server/output.rs:331 sets finished = true before the error so abort() cannot re-run the parser.
S3 — the strict grammar re-creates exactly the N-way alternation the description says it avoids, with no coverage at realistic tool counts [Architecture, Correctness, Simplicity]
Finding. compile_content_headers factors the unnamed header through one synthesized schema whose name is {"enum": &envelope.tools} (grammar.rs:381-391), justified in the description as "avoiding N-way Earley ambiguity across large tool sets". compile_strict_tml instead emits tool_unnamed: <|content_invoke_tool_json|> (@payload_0 | … | @payload_k) <|end_message|> (strict.rs:1599-1603), one complete wrapper schema per active tool pushed at strict.rs:1581-1586 (all tools are collected whenever tool_choice != None, server/request.rs:225-241 (not opened)). Largest new test coverage is two tools (strict.rs:4618-4634, :4134-4143); live strict evidence is one tool (get_weather); the 178-tool measurement is on the non-strict path only. Size budgets (grammar.rs:22 MAX_GRAMMAR_BYTES = 262_144, checked at strict.rs:2443-2455; admission max_lexer_states: 32_768) bound size, not ambiguity, and an over-limit grammar is rejected at admission rather than degraded.
Request. State in the PR — and in one comment above strict.rs:1599 — why the alternation is right for strict tools (embed_schema_in_tml_wrapper at strict.rs:873-892 folds the tool name into each payload as a const, so name and arguments cannot be split the way grammar.rs splits them), and add a compile/advance test at a representative tool count; or factor it as the sibling path does.
Why. Two grammars that both claim to mirror TmlOutput now differ in construction with only half the stated rationale applied, and a many-tool "strict": true request is unmeasured. The comment also stops the next reader from "unifying" the two rules and breaking one.
S4 — two of the three new ignored snapshot tests are one test, and none of them uses the generated reference fixture [Conventions, Simplicity]
Finding.
inkling_stress_untyped_closed_header_must_surface_failure(tml_tests.rs:393-439) sends byte-identical tokens toa_model_frame_without_a_content_kind_reports_a_failed_response(tml_tests.rs:246-282): sameInklingfixture, sameProtocol::Responsesrequest, the same singlebashtool, differing only by an explicit"tool_choice":"auto"(:403) that is already the default. The token lists match (:265-270vs:418-424), and the second asserts a subset of the first's properties (the first also assertserror.code == "server_error"at:280and the per-push reasoning-only invariant at:273). Both are#[ignore]d, run with--ignored --test-threads=1, so the duplicate pays a second snapshot load for no extra signal.- Neither test goes through the reference path. The file's contract is that checkpoint tests compare Helios with
tests/frontend/inkling2_tml.json(not opened), generated bytests/frontend/generate_inkling2_fixtures.py(tml_tests.rs:7-12), and that generator records{"error": …}when tml-renderers itself rejects a sequence (generate_inkling2_fixtures.py:399-417), whichoutputs_match_reference_parses(tml_tests.rs:286-299) already asserts against. The malformed-header case is hard-coded raw IDs instead, so nothing shows tml-renderers rejects the same suffix — whiletml.rs:7-15claims the parser matches it. - Separately,
a_closed_untyped_header_allows_visible_content_and_completed_calls(tml.rs:626-639) computesexpected = run(...)and compares it againstrun(...), i.e. the parser with itself; a uniform behaviour change keeps it green.
Request. Delete inkling_stress_untyped_closed_header_must_surface_failure (fold the tool_choice: "auto" variant into the earlier test's body if it matters); add one output(...) case for the malformed terminal header to generate_inkling2_fixtures.py, regenerate inkling2_tml.json (not opened), and assert both the Helios failure and case["reference_parse"]["error"] there; in tml.rs:626-639 assert literals as the neighbouring tests do (tml.rs:543-561): ("".into(), "done".into(), vec![]), ("".into(), String::new(), vec![("lookup","{}")]), ("".into(), "invalid JSON".into(), vec![]). If the fixture cannot be regenerated in this PR, say so under "Unrun Checks and Limitations".
Why. AGENTS.md:189-194 asks for focused, meaningful validation; a test that cannot fail unless another fails is churn (AGENTS.md:183-188), and an inline token list cannot establish the cross-implementation agreement the module doc claims.
S5 — the description's evidence is not reproducible from this branch [Prose]
Finding.
- Live GPU evidence is attributed to "
TML-d24-varloop-researchon RTX PRO 6000 Blackwell", butignition/recipes/inkling2/config.py:88-92rejectsis_varloop: true("Inkling 2 preparation requires a fixed loop pass count"),tests/recipes/test_inkling2_mini.py:87(not opened) asserts that rejection, and the alias survives only in closed #468. - The snapshot command reads
FLARE_INKLING2_TEST_SNAPSHOT=...althoughtml_tests.rs:9-12states what the variable must contain; it is also not thecargo testinvocation, and every test it selects is#[ignore]d (tml_tests.rs:103,:161,:247,:285,:302,:351,:394,:442), so the separate "124 passed" line does not cover them. agentic_suite.py(not opened), cited for the multi-turn round-trip suites, has no match in the repository and no path.- "124 passed" quotes module prefixes but the quoted
cargo testline carries no filter; "5/5tool calls (4/5['reasoning','message','function_call'])" leaves the fifth preamble run unexplained.
Request. Name the served core as a reviewer could obtain it (checkpoint repository and revision plus a recipe alias that exists on this branch), or state plainly that it is external and not reproducible in this repository; give the full snapshot invocation with what the variable must point at and the --ignored requirement in the same sentence; give agentic_suite.py (not opened)'s path or say it lives in the external recipes tree; state the filter behind 124; explain the 4/5.
Why. AGENTS.md:90-107 — the scope and material limitations of a measured result must travel with it, and reproduction commands must identify required inputs directly or through a precise reference; placeholder arguments alone do not explain a measurement.
S6 — grammar and parser still disagree, in the opposite direction [Correctness]
Finding. Both new endings require a <|message_model|> restart between a visible answer and a following tool call (grammar.rs:405, strict.rs:1616-1618), but TmlOutput opens State::Body { kind: Call, model: true } from a content_invoke_tool_json control token directly after <|end_message|> with no restart (tml.rs:250-258). So <|message_model|><|content_text|>hi<|end_message|><|content_invoke_tool_json|>{…}<|end_message|> parses as a call and is rejected by both new grammars.
Request. Accept the restart-less form in the endings, or state in the description and in the S1 paragraph that a restart is required when a grammar is active.
Why. The PR's headline is alignment with TmlOutput; a residual divergence means a constrained request rejects a frame sequence the parser accepts — the same class of defect the PR fixes in the other direction. It affects only requests that set a grammar, which is why it is not a blocker.
Nits
N1 — the wire-token splitter is copied a fourth time [Conventions, Simplicity]
The encode closure in strict_tml_grammar_allows_unnamed_headers_and_preamble_before_tools (strict.rs:4572-4588) is character-for-character the one in strict_tool_wire_grammars_enforce_constraints (strict.rs:4205-4221); the same marker scan exists at protocol/tests.rs:466-470 and as pieces() at protocol/tests.rs:2048-2066; the byte-tokenizer setup at strict.rs:4546-4551 repeats strict.rs:2814-2819. Meanwhile the other new grammar test encodes its wire strings a different way (tokenizer.encode(...), grammar.rs:1987-1994).
Request: hoist one wire_tokens(controls, wire) helper beside byte_tokenizer_with (grammar.rs:936) and call all four sites; optional compiler_with_controls(&tokenizer).
Why: the splitter encodes the invariant "control markers are one token, everything else is bytes", so a marker-rule change now means editing several copies (AGENTS.md:183-188).
N2 — test names and #[ignore] wording [Conventions, Prose]
inkling_stress_untyped_closed_header_must_surface_failure (tml_tests.rs:395) and inkling_stress_custom_grammar_preamble_then_tool (:443) carry a stress label that names no property, while every other test in the file names the behaviour (:104, :162, :248, :286, :352). Their #[ignore] messages read "with an Inkling 2 tokenizer" (:394, :442) where every other reads "with the" (:103, :161, :247, :285, :302, :351).
Request: drop stress (untyped_closed_header_must_surface_failure, custom_grammar_allows_preamble_then_tool) and align the article.
Why: .agents/skills/repo-prose/SKILL.md (not opened) forbids lifecycle/experiment labels as identities, and AGENTS.md:38-45 makes that skill mandatory for names.
N3 — the new terminal error narrates cause instead of naming the state [Conventions, Prose]
"TML model header closed without a content kind and the turn produced no answer or tool call" (tml.rs:399-401) versus the family: "unterminated recipient header" (recipient.rs:293 (not opened)), "incomplete XTML output envelope" (xtml.rs:246 (not opened)), "incomplete DeepSeek tool call at end of response" (dsml.rs:380 (not opened)), format!("incomplete {} tool call", D::NAME) (tagged.rs:301 (not opened)). The string is client-visible through Encoder::failure (protocol/encode.rs:760).
Request: shorten to the family form, e.g. "incomplete TML model frame", updating the three assertions that pin the current wording (tml.rs:608, :622, tml_tests.rs:281).
Why: the sibling parsers state the incomplete state; the message is API-visible prose, not an internal detail.
N4 — small trims in the new tests and rules [Simplicity]
empty_model_headers_other_roles_and_external_stops_keep_their_termination re-asserts USER/TOOL/SYSTEM frames (tml.rs:644-646) already covered by the richer frame at tml.rs:548-551 (keep the genuinely new [MODEL, END] case and the four external terminations); payload_refs (strict.rs:1566, pushed at :1586) exists only to feed one format! at :1602; inkling_stress_custom_grammar_preamble_then_tool repeats four accept-only assertions already in content_headers_grammar_allows_preamble_before_tools (grammar.rs:1973-1978).
Request: keep one of each pair; build tool_unnamed inside the existing loop or from tool_rules.
Why: churn against AGENTS.md:183-188; each duplicate is a second place to maintain.
N5 — prose in the PR itself [Prose]
The title leads with an internal type name and stacks three changes ("… align … with TmlOutput"), and the three commit bodies are subject-only (76c50158, 9b2f2f6a, aacbca18) although docs/design-review.md:137-147 (not opened) requires the four-part argument in the commit message too, with :169-174 making that review a gate.
Request: lead the title with the user-visible consequence (malformed TML turns failing instead of silently completing; TMLv0 grammars accepting unnamed tool headers and a preamble before tool calls) and fill the commit bodies before merge.
Why: AGENTS.md:117-123 asks that a component's role be explained before its shorthand is used, and git log alone should let a reader reconstruct the argument.
N6 — the unrun list omits the strict-TMLv0 combinations this PR's changed endings govern [Architecture]
docs/TODO.txt:25-28 names them: strict: true function tools on a TMLv0 core served by flare run, Chat Completions and Responses, buffered and streamed, including max_tokens/max_output_tokens truncation. The PR changes the single_call and non-single_call endings (strict.rs:1613-1619) and its live strict evidence is one tool on /v1/responses; "Unrun Checks and Limitations" mentions non-TMLv0 families and non-model role frames but not these.
Request: run them, or list them as unrun with a pointer to docs/TODO.txt:25.
Why: AGENTS.md:189-194 requires unrun checks to be identified, and docs/api.md:621-625 already promises truncation behaviour for a strict call — exactly the path the new ending has to survive.
Open questions for maintainers
- Are empty answer frames legitimate in TMLv0?
<|content_text|><|end_message|>with no bytes, and[MODEL, THINK, "t", END, TURN_END](assertedOkattml.rs:652-653), decide whether S2 is a bug or a documented boundary. - What is the intended tool-count ceiling for
"strict": true? Without a stated bound, S3 can only be settled by a compile/admission test at realistic counts — neither side of the argument is measurable from the code. - Is a restart-less tool frame after a visible answer legal (S6)? The parser says yes, both new grammars say no.
- Does tml-renderers reject the captured malformed terminal header? Only a regenerated
outputs[].reference_parse.errorcase answers it; if it does not, the new EOS error is a Helios-specific interpretation and the description should say so (S4). - Does the maintainers' reading of AGENTS.md:225 include TMLv0 frame syntax in
docs/api.md? If the intent is silence on frame grammar, S1 becomes a nit, but the description should then say where the contract lives. - Which of the two production grammar changes produced the 0/5 → 5/5 live improvement —
tool_unnamed, the new ending, or the fact that a(?s:.+)answer body can itself swallow raw tool JSON? The tests separate schema rejection from framing, not these two changes from each other.
What could not be verified
- Nothing was built or run in this review: no
cargo test, no snapshot suite (noFLARE_INKLING2_TEST_SNAPSHOTavailable), no GPU. All statements are read from source and from the PR's own reported results. - CI on head
aacbca1reports no checks, so the PR is not machine-verified at merge. - The claim that the two ignored snapshot tests produce identical token streams rests on reading the code; running both with
--ignored --test-threads=1and comparing would confirm it. - Per-token parse cost and ambiguity of the strict N-way
tool_unnamedat large tool counts needs an admission test or benchmark, not code reading. - Any live serving behaviour on non-TML parser families, non-SM120 hardware or multi-host layouts is untouched by the diff and therefore unproven rather than risked.
agentic_suite.py(not opened) anddocs/model-preparation.md(not opened)'s TMLv0 mentions were not opened.