#1 [high] Research summary
Reviewed PR #575 (Preserve raw JSON tool arguments in TmlOutput) through the correctness lens. I could not use the scratchpad (time ran out), so the findings are below in full.
What I verified in code
TmlOutput::callbefore/after (helios/src/output/tml.rs:329-363): the newRawCallstruct with#[serde(deny_unknown_fields)]and#[serde(borrow)] args: &'a RawValuereproduces the set of prior rejections that fall back to visible text.serde_json::from_str::<&RawValue>validates JSON syntax, soargsis a syntactically valid JSON value, andargs.get().trim().starts_with('{')is equivalent to the removedis_object()check. Unknown wrapper keys still fail (now viadeny_unknown_fieldsinstead ofobject.len() != 2), and the tool-name / recipient-header checks (votingtools[]andself.name) are unchanged in meaning. Duplicate wrapper keys are now rejected instead of silently collapsed byserde_json::Value(test at tml.rs:619-628) — a deliberate tightening, not a compatibility break for grammar-constrained output.- Downstream consumers keep the raw text:
Accumulator(helios/src/server/output.rs:78-123) appends the argument text into a JSON string and only parses it inToolEndto assertis_object;ResponseOutput(output.rs:1378-1418) does the same; the Responses item and Chattool_callsencodearguments.as_str()verbatim (helios/src/server/protocol/encode.rs:313, 441). So Chat Completions and Responses — buffered and streamed — do now carry the unrounded integer, matching the new Python test. - Strict validation happens on exactly the emitted bytes:
Encoder::applyaccumulatesEvent::ToolArgumentstext and validates it atToolEnd(encode.rs:523-553), i.e. the sametrim-ed stringTmlOutputproduced, soOutputEncodercannot re-serialise and mismatch (grammar.rs:631-657). - Golden TML fixtures are not broken by raw preservation: helios/src/server/request/tml_tests.rs:200-260 compares parsed
Values (e.g.{"q": "x", "n": 2.50}→{"q":"x","n":2.5}for the case generated at tests/frontend/generate_inkling2_fixtures.py:464-467), not raw argument text, and the malformed/unregistered/mismatched-header cases at generate_inkling2_fixtures.py:443-497 still fall back to text under the new rules. - Truncation semantics are unchanged and consistent with the new test: helios/src/output/tml.rs:377-384 publishes a call body only at
Termination::Eos, so amax_tokens-cut call leaves notool_callsand no pending strict call for encode.rs:599-603 to error on.
Findings
- Should fix (scope/claim): the "arbitrary-precision preserved end to end" claim only holds for Chat Completions and Responses. The Anthropic Messages encoder still round-trips arguments through
serde_json::Value—helios/src/server/protocol/encode.rs:334(tool_use.input) — and the custom-tool path at encode.rs:298-303/404-415 does the same.serde_jsonhere is built withoutarbitrary_precision(helios/Cargo.toml:52), so123456789012345678901234567890becomes1.2345678901234568e29ininput. This is pre-existing and shared with the Qwen/GLM/DSML raw paths, and the PR's Python test covers only Chat and Responses (tests/server/test_inkling2.py:121-210), so the Messages path is untested and unqualified. Fix: either extendtest_strict_tml_tool_calls_and_truncationto/v1/messages, or state the Messages limitation in the description/docs (docs/api.md:588-628 currently says nothing about it). - Nit: the emitted arguments are
parsed.args.get().trim()(tml.rs:339), so the text is no longer byte-verbatim as the PR description claims "verbatim"/"exact JSON argument text"; leading/trailing whitespace inside the wrapper'sargsvalue is dropped. Harmless (still valid JSON, and the validator sees the same trimmed bytes), but the description should say "whitespace-trimmed raw text". - Nit: duplicate keys inside
argsare now passed through byte-for-byte instead of being collapsed last-wins byserde_json::Value. Strict grammars forbid them, but non-strict TML invocations can now surface{"a":1,"a":2}to the client, unlike the DeepSeek path which rejects non-unique argument names (helios/src/output/dsml.rs:386-414, documented at docs/api.md:449-452). Worth either documenting or matching DSML's unique-key check.
No blocking defect found in the changed TML code itself: rejection semantics, fallback-to-text recovery, name/header validation, index allocation, streaming buffering and truncation behaviour all match the previous contract, and the new tests exercise the real OutputPipeline/OutputEncoder entry points as required by docs/design-review.md (testing hierarchy, principle 12) and are gated on the existing FLARE_RUN_CUDA_TESTS/Inkling 2 harness like the neighbouring tests.
#2 [high] Should fix: Messages (Anthropic) path still rounds big integers in tool arguments
PR #575 "Preserve raw JSON tool arguments in TmlOutput" (helios/src/output/tml.rs:329-363).
Finding (should fix): the claim that arbitrary-precision integers survive end to end only holds for Chat Completions and Responses.
- Anthropic Messages encoder: helios/src/server/protocol/encode.rs:334 —
"input": if complete { serde_json::from_str::<Value>(arguments).unwrap_or(json!({})) }. serde_json is built WITHOUT arbitrary_precision (helios/Cargo.toml:52: features preserve_order, float_roundtrip, raw_value), so123456789012345678901234567890becomes1.2344568e29-style binary64 intool_use.input. - Same round-trip in the custom-tool path: encode.rs:298-303 (Responses
custom_tool_callinput viaserde_json::from_str::<Value>(arguments)), encode.rs:404-415. - This is pre-existing and shared by the Qwen/GLM/DSML raw-argument parsers, so not introduced here, but the PR's evidence set does not cover it: tests/server/test_inkling2.py:121-210 only exercises /v1/chat/completions and /v1/responses.
- Fix: add a /v1/messages case to test_strict_tml_tool_calls_and_truncation, or disclose the Messages limitation in the PR description and docs/api.md:588-628 (strict-tool section says nothing about precision on output).
Nit: emitted text is parsed.args.get().trim() (tml.rs:339), so it is whitespace-trimmed, not strictly "verbatim"/"exact JSON argument text" as the description says. Harmless: the strict validator is fed the same trimmed bytes (encode.rs:523-553), and the trimmed text is still valid JSON.
Nit: duplicate keys INSIDE args are now passed through byte-for-byte (previously collapsed last-wins by serde_json::Value). Strict grammars forbid them, but non-strict TML calls can now surface {"a":1,"a":2} to clients, unlike DeepSeek DSML which rejects non-unique argument names (helios/src/output/dsml.rs:386-414; documented docs/api.md:449-452). Document or match DSML.