Case file — PR #575: Preserve raw JSON tool arguments in TmlOutput for strict TMLv0 calls
PR: https://github.com/NVIDIA/hyperflare-inference/pull/575 · author fordbmorris (commit author woooflet) · branch pr/tml-output-raw-json-args · head 07955d7 · base main, rebased onto 167f22c · opened 2026-11-28 · open, ready for review, 3 files, +237 / −10 · no labels, no reviews, no CI checks.
Key findings
- The change does more than the description says for non-strict TMLv0 calls.
TmlOutput::call(helios/src/output/tml.rs:329-363) is the parser for every TMLv0 tool call; strict validation happens much later inOutputEncoder(helios/src/server/protocol/encode.rs:517-553). Switching the emit fromargs.to_string()toargs.to_owned()means non-strict TMLv0 arguments also stop being normalized by serde: whitespace inside the object, number spellings (e.g.1e20vs1.0), escape spellings and duplicate keys insideargsnow reach the client verbatim. Only the >64-bit-integer precision case is cited as motivation. - It also newly rejects duplicate wrapper keys, which the description frames as preserved prior behaviour. The old
object.len() == 2check accepted{"name":"x","name":"x","args":{}}(serde collapses duplicates into a 2-entry map); the new#[serde(deny_unknown_fields)] struct RawCall(tml.rs:330-336) fails it and falls back to visible text. That is a tightening, not "matching prior TMLv0 recovery semantics". - "Preserves property order" is not new. helios/Cargo.toml:52 already enables
serde_json'spreserve_order, so the oldValueround-trip already kept insertion order. The same line already enablesraw_value, so the change adds no dependency feature. - The live evidence is not reproducible from the repo. The Rust counts (7/7, 28/28, 2/2, 5/5), the "35/35 live 4-Spark TP4" run and the "6/6 invalid-schema HTTP 400 admissions" appear nowhere in the diff or repo; the committed
tests/server/test_inkling2.pycontains one new test with about five assertion groups, and no CI workflow runs pytest at all, so it only ever runs manually against a live 4×GB10 service (skipif gate at tests/server/test_inkling2.py:23-26). Only the two new Rust unit tests are actually executed by CI (.github/workflows/native-serving.yml:63 (not opened)). - Related in-flight work touches the same function. #457 (open,
brandonmmusic-max) rewrites the sameTmlOutput::calland the same strict TMLv0 grammar on its own branch and still usesargs.to_string(). Neither PR supersedes the other; whoever merges second resolves a conflict inTmlOutput::calland in themod testsblock of tml.rs. #461 (open) documents the adjacent numeric-precision boundary but leaves unboundedintegerproperties — exactly #575's case — unrestricted. - docs/TODO.txt:5-8, the tracked item the PR says it "addresses", is not edited. It stays open after merge unless a maintainer ticks it; AGENTS.md:57-60 directs qualification scope into docs, and reviewers required exactly that of #418 and #457.
- Two residual precision paths remain unfixed and undisclosed: Anthropic Messages
tool_use.inputstill re-parses arguments throughserde_json::Value(encode.rs:328-335), and the prompt-side TML renderer re-serializes arguments when replaying a prior assistant turn (helios/src/frontend/tml.rs:148-174,write_json:71-117). - Provenance and attention. First-time contributor (GitHub association NONE), four unrelated PRs opened the same day (#574, #575, #576, #577), none reviewed. Zero comments/reviews/reactions on #575 and no flare-autobot case file, whereas #457 and #461 both drew CHANGES_REQUESTED autobot reviews within about two days. CI did not trigger on the head commit.
The change
Size and shape. pr_files: helios/src/grammar/strict.rs +105/−0 (test only), helios/src/output/tml.rs +41/−10, tests/server/test_inkling2.py +91/−0 (one new live test).
Before: TmlOutput::call parsed the invoke body into serde_json::Value, required an object of len() == 2 with a string name and an object args, and emitted args.to_string().
After (verified, helios/src/output/tml.rs:329-363): a function-local #[derive(Deserialize)] #[serde(deny_unknown_fields)] struct RawCall<'a> { name: String, #[serde(borrow)] args: &'a RawValue }; serde_json::from_str(body).ok()?; then three guards — args.get().starts_with('{'), the tool name must appear in self.tools (tool["function"]["name"] == parsed.name), and the optional recipient header must equal name (self.name.as_ref().is_some_and(...)) — before emitting ToolBegin / ToolArguments { text: args.to_owned() } / ToolEnd. Any failure returns None, and call_or_text (tml.rs:318-327) then emits the body as visible Content. The struct is local, so no public API change; #[serde(borrow)] keeps it zero-copy.
Tests added. helios/src/output/tml.rs:608 call_preserves_raw_json_arguments_including_arbitrary_precision_integers (also asserts a duplicate "name" key falls back to visible text); helios/src/grammar/strict.rs:3820 tml_strict_parser_preserves_30_digit_integers (GrammarCompiler + OutputPipeline + strict TextGrammar validation across top level, anyOf, $ref, and nested array/object, asserting the 30-digit value survives). tests/server/test_inkling2.py adds test_strict_tml_tool_calls_and_truncation (~91 lines): Chat Completions buffered + streamed, max_tokens=10 truncation, Responses buffered, max_output_tokens=10 truncation.
Why the fix works (worth stating because it is the real correctness argument): the strict wire grammar emits {"name": …, "args": …} itself (embed_schema_in_tml_wrapper, helios/src/grammar/strict.rs:873-892), so forwarding the raw bytes means the encoder validates the exact text it produced.
What the description does not say — see Key findings 1-3, plus:
args.get().starts_with('{')replacesvalue.is_object(). A payload written as"args": {…}with whitespace after the colon is not covered by any test; ifRawValue::get()retains leading whitespace the call would be rejected. Only non-strict generation can produce such spacing (the strict grammar emits compact JSON), so the practical exposure is the non-strict fallback path. #418's DSML work explicitly tolerates "both DSML's spaced JSON and compact JSON".- The
nametype change (Stringvia serde instead ofas_str()) is behaviourally equivalent; the existing case{"name":7,"args":{}}(tml.rs:557) still falls back to text.
The why
Per the PR body: with ToolParserKind::TmlJson (Inkling 2) and a strict: true tool whose schema declares an unbounded {"type": "integer"}, constrained decoding may emit a 30-digit integer such as 123456789012345678901234567890. The old serde_json::Value round-trip (no arbitrary_precision feature anywhere in the repo) renders it as binary64 1.2345678901234568e29; OutputEncoder re-validated that against the compiled strict TextGrammar, saw a float where an integer was required, and failed the live request with HTTP 500.
Verified chain for that failure: the message format is helios/src/grammar.rs:653 format!("{subject} does not match its grammar") with subject "strict tool arguments" (grammar.rs:632-636); it is raised from OutputEncoder (encode.rs:539-541) and surfaced as StatusCode::INTERNAL_SERVER_ERROR (helios/src/server/http.rs:278 (not opened)) — i.e. a server fault, matching the description.
Dated demand timeline: #417 filed 2026-11-20 (strict tools rejected outright; "several common clients send strict: true by default, so they cannot use Flare at all") → #418 merged 2026-11-22 adding strict tools for DSML/Qwen/GLM/TMLv0, whose body states no TMLv0 core was served and which added docs/TODO.txt:5-8 → #575's single commit dated 2026-11-26, PR opened 2026-11-28. So the gap was acknowledged six days before this PR; the demand is a tracked TODO item plus a prototype-serving need, not a user bug report — no issue in the local copy reports the >64-bit rounding or the strict-grammar 500.
Related work
- #418 (merged, 2026-11-22,
0b09434d, jcartu, closes #417) — created both the gap and the precedent. It added strict function tools to DSML/Qwen/GLM/TML parsers; revieweryatesdraccepted "TML: fixtures are enough" only on condition the unserved check be recorded, which produced docs/TODO.txt:5-8. It also established the raw-token strategy #575 extends: Qwen/GLM strict parsers keep raw JSON viaRawArguments/Box<serde_json::value::RawValue>(helios/src/output/tagged.rs:805-860, helperstrict_nonstring_raw:846-860, doc comment "Preserve exact raw JSON tokens (such as >64-bit integers)"), and DSML passes source text through (helios/src/output/dsml.rs:152-192).TextGrammar::validatealready accepts ">20-digit integers (123456789012345678901234567890)". So the PR body's "matching the raw-token preservation already used by the Qwen, GLM, and DeepSeek DSML parsers" is accurate. - #457 (open,
brandonmmusic-max, +431/−7) — rewrites the sameTmlOutput::callplus the same strict TMLv0 grammar (the exact two Rust files of #575). On its branch the function is still the oldValue/args.to_string()form wrapped by a newcall_or_textthat setsAnswerState::Emitted, so it does not fix this defect and #575 does not implement its AnswerState/EOS/unnamed-header grammar work. Overlapping and textually conflicting in bothTmlOutput::calland themod testsblock; neither supersedes the other. #457 also carries an open CHANGES_REQUESTED autobot review (2026-11-24, no blockers, 5 should-fix + 6 nits) that flags "the strict-TMLv0 truncation checks from docs/TODO.txt:25-28 neither run nor listed" — the same truncation qualification #575's new Python test claims. - #461 (open, jcartu, +39/−14) — documents the same numeric-precision boundary in docs/api.md:600-605 (const/enum must be below 2^53; bounds round through f64). It does not restrict unbounded
integerproperties, which is precisely #575's case, so the two are complementary; it touches strict.rs only in a test, no conflict with #575's added test at strict.rs:3819-3923. - #191 (open, draft,
YouNeedCryDear) — the PR that first added helios/src/output/tml.rs; still draft, blocked on recipe work moved out of this repo by 17bb3c4a. - #312 (open, draft), #304 / #305 (merged) — share tests/server/test_inkling2.py. #312 works on branch
inkling2/spark-performance(different base), so a textual conflict with #575's +91 in that file is possible but the branches are not stacked. - Undone/reversed by this PR: nothing.
- Not relevant (matched only on incidental names or a superficially similar theme): #433, #428, #281, #193, #133, #228, #39. #39 (closed, GLM argument-tags) is the nearest prior class of report — a type-mismatched argument aborting the stream — but a different parser and different defect.
Recent activity
- helios/src/output/tml.rs prior commits:
dc0d40e0"Harden Helios HTTP ingress, frontend bounds, RoCE/TP lifecycle, and crate boundaries" (Luke Alonso, 2026-11-19) and8628b7c5"Prepare Inkling 2 Small NVFP4 for native TP4 serving" (Luke Alonso, 2026-11-14). - helios/src/grammar/strict.rs has only two commits ever:
0b09434d(#418, jcartu, 2026-11-22) and #575's07955d70. #575 lands on a six-day-old file and is only the second change to it. - helios/src in the last 60 days is dominated by Luke Alonso (212), Martin Vit (51), yatesdr (47); tests/server by Luke Alonso (32), yatesdr (4), derek (3). The Inkling 2 serving tests came from original-el8 (#304/#305), Nero (#433) and Jason Cook (
1b9a1082). - No commit on main since
167f22ctouches any of #575's three files; the PR body states it "rebased cleanly onto167f22c8". Consistent with a conflict-free rebase, but also means nobody has yet had to reconcile it with anything. 17bb3c4a(Luke Alonso, 2026-11-22) removed extractedhyperflare_recipes, qualification drivers and model tests from this repo; #575 stays inside the runtime repo, consistent with that split.
People
- Author:
fordbmorrison GitHub,wooofletas commit author and in the PR's "Discord: woooflet" line — one person, two handles. GitHub association with the repo: NONE. In the last 180 days: 0 merged, 0 closed, 3 open (#574 AOT guard pickling, #576 thread pinning, #577 roce_proxy ring mailbox) — all opened 2026-11-28, none reviewed. Four unrelated PRs in a single day from a first-time contributor. - Usual owners of these areas: strict tools were driven by
jcartu(#418, #461) and gated by revieweryatesdr, whose stated bar across #417/#418/#461 is that unrun live checks be listed, claims name a revision and command, and scope be recorded in docs. The charter names@voipmonitor,@original-el8,@lukealonsoas priority contributors; the author is none of them. - Engagement so far: none. No reviewer, no comment, no reaction, no autobot case file.
Community
Zero comments, reviews or reactions on #575 (its discussion is empty), in contrast to #457 and #461, each of which drew an autobot case file and a CHANGES_REQUESTED review within about two days. Demand for the underlying fix is visible only indirectly: #417's "clients cannot use Flare at all", the open docs/TODO.txt:5-8 item, and #461's documentation of the precision boundary. The PR is follow-on polish to a feature merged six days earlier, not a response to a filed report.
Project fit
- Aligned: the charter targets "the documented subset of the OpenAI API … and JSON Schema for structured outputs"; a strict tool that cannot emit a schema-valid integer, and answers HTTP 500 (a server fault), is a defect within that target.
- Aligned: "Bring real evidence… Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error" — #575 stops normalizing the JSON text rather than catching the validator error.
- Aligned: "Keep the runtime small and model-agnostic… shouldn't accumulate per-model branches" — no per-model branch, flag or config; one generic parser path.
- Aligned: AGENTS.md:72-113 requires a four-part description; #575 has Why / What Changed / Claimed Benefit / Supporting Evidence.
- Tension: AGENTS.md:57-60 requires qualifications to state hardware, configuration and what is not qualified, and AGENTS.md:58 sends unresolved defects and unrun checks to docs/TODO.txt. #575 records scope only in its body ("Qualified live on Inkling 2 Small NVFP4…; non-TML tool parsers are untouched") and edits neither docs/TODO.txt (its own claimed target, lines 5-8) nor docs/api.md. #418 and #457 were both required by review to update those files. docs/api.md:443 documents that "Tool arguments are JSON objects" but says nothing about numeric preservation, so documentation readers learn nothing from this change; docs/api.md:624-628 already documents the truncation behaviour the new Python test exercises.
- AGENTS.md:230 lists "Change CLI, API, or configuration behavior → docs/api.md"; #575 changes no HTTP schema, so arguably not triggered — although it does change client-visible argument bytes for non-strict TMLv0 calls.
Claims and evidence
Verified in the repository:
- The mechanism and the error string: grammar.rs:653 → encode.rs:539-541 → http.rs:278 (not opened) (HTTP 500).
- No dependency change needed:
raw_valuealready on at helios/Cargo.toml:52. preserve_orderalready on at the same line, so order preservation predates this diff.- No
arbitrary_precisionfeature anywhere in the repo, consistent with the >u64 → f64 loss. - The truncation semantics the new Python test asserts ("unfinished strict calls cleanly omitted") are pre-existing: encode.rs:532-553 drops a pending strict call unless
ToolEndarrives, documented at docs/api.md:624-628. - The two new Rust tests are run by CI (.github/workflows/native-serving.yml:63 (not opened) runs
cargo test --locked --release --features runtime-core,serveron ubuntu-24.04 and windows-2022).
Claimed but not reproducible from the repo:
- Rust test counts (7/7
output::tml, 28/28grammar::strict, 2/2server::protocol::tests::strict, 5/5server::request::tml_tests) — no logs attached, counts not in the diff. - The "35/35 (100%)" live 4-Spark TP4 Inkling 2 Small NVFP4 qualification, covering nested/recursive
$ref, unicode/escaped quotes, parallel and single-call enforcement, multi-turn roundtrips, mixed strict + non-strict tools, strict tool +json_schemaresponse format, and "6/6" HTTP 400 admission rejections — the 35-case harness is not in the repo; the committed Python test holds one test with roughly five assertion groups and covers none of those cases. - The new Python test is gated on
FLARE_RUN_CUDA_TESTS=1andFLARE_INKLING2_TEST_URL(tests/server/test_inkling2.py:23-26) and its fixture asserts ≥8 concurrency, 4096/8192 prefill chunk and image modality (lines 29-38), so it needs a live 4×GB10 TP4 service. No workflow runs pytest, so it will never run in CI. - CI did not run on the head commit at all; the described test run is ARM64 GB10 only, so
&'a RawValuebehaviour on the two CI targets (x86_64 Linux, Windows) is unexercised.
Reach
- Affected: every TMLv0 core (
ToolParserKind::TmlJson) — pipeline.rs:78 routes that kind toTmlOutput; strict gating happens later at encode.rs:517-553. That is Inkling 2 Small/Mini here (and #191's Inkling-Small). No core re-export, Protobuf field or recipe change is required, consistent with the diff touching no proto or recipe files. - Client-visible beyond the fix: non-strict TMLv0
argumentstext is now the exact generated bytes (whitespace, escapes, number spellings); duplicate wrapper keys now fall back to visible text instead of parsing. Chat Completions passes the raw string through (helios/src/server/output.rs:113-121 parses it only to check it is an object, then discards the value, so no precision loss); Responses and Anthropic re-parse to values (encode.rs:300, :334, :408) and are semantically unaffected. - Unfixed residual paths: Anthropic
tool_use.inputre-parses viaserde_json::Value(encode.rs:328-335), so a 30-digit integer reaching a Messages client would still round there — although docs/api.md:634 says strict tools on Messages return 400, so reachability is unclear. Prompt-side, the TML reference renderer re-serializes arguments when replaying a prior assistant turn (helios/src/frontend/tml.rs:148-174, floats via ryu at :71-117, test at :567-573 shows1.50→1.5), so a client echoing an oversized integer in a later turn goes through a path no test covers — relevant to the description's "multi-turn tool roundtrips" claim. - Operators / config / deployment: no new flags, defaults, dependencies or resource bounds (parser limits unchanged at tml.rs:266-292); the fix ships with the
flarebinary and applies to already-exported cores on upgrade. No performance claim. - Test infrastructure: only the two Rust tests get automated execution; the Python qualification is manual-only.
Process
- State: open and ready for review; opened 2026-11-28 19:22 and unedited since — under a day old at review time.
- CI: no checks on
07955d7, even though the repo's native-serving workflow would run the relevantcargo teston Linux and Windows; the workflow apparently did not trigger. - Review: no reviews, no comments, no labels, no autobot intake — unlike #457 and #461.
- Process signals a reviewer may weigh: single commit
07955d70dated 2026-11-26 but a PR opened 2026-11-28; the body cites the base as167f22c; noSigned-off-byvisible in the metadata, and DCO sign-off was an explicit merge gate jcartu had to satisfy on #418 (yatesdr: "We will review the revision … with Signed-off-by on every commit") — AGENTS.md does not mandate DCO, so this is precedent-based, not verified policy. - The description says it "addresses" docs/TODO.txt:5-8 but does not edit that file, so the item stays open unless a maintainer ticks it.
- Same-day batch (#574/#575/#576/#577) means one reviewer is facing four unreviewed PRs at once from the same author.
Open questions / not found
- Whether the described 35/35 live qualification and the Rust test counts exist anywhere (logs, harness, an internal run) — not in the repo.
- Whether the Anthropic Messages path can reach a strict TMLv0 tool at all (docs say strict on Messages tools returns 400), i.e. whether the
tool_use.inputre-parse is a real residual defect or dead code for this case. - Whether a spaced
"args": { … }payload from non-strict generation survives the newstarts_with('{')guard — untested. - Whether >u64 integers survive the prompt-side re-render in frontend/tml.rs on a multi-turn roundtrip — untested.
- Whether DCO sign-off is required for this repo; no policy statement found in AGENTS.md.
- No user issue, bug report or third-party comment reporting this defect anywhere in the searchable local copy; the demand trail is #417 → #418 → docs/TODO.txt:5-8 → #575 only.