Repository navigation
Preserve raw JSON tool arguments in TmlOutput for strict TMLv0 calls - #575
Conversation
|
A case file has been opened for 575. Future reviews will auto-run 90 minutes after code updates are pushed.
|
07955d7 to
c7fae93
Compare
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Ready To MergeThe production fix in
Have your agent review the Full Review for complete verified findings, To opt out, include |
When a TMLv0 core serves a `strict: true` function tool whose JSON Schema
declares an unbounded integer property, constrained generation can emit an
integer exceeding 64 bits (for example, a 30-digit identifier). Previously,
`TmlOutput::call` in `helios/src/output/tml.rs` deserialized the invocation
payload through `serde_json::Value` (which lacks `arbitrary_precision`) and
re-serialized `args` via `Value::to_string()`, silently rounding integers
above `u64::MAX` into scientific-notation binary64 floats. `OutputEncoder`
then rejected the re-serialized string against the compiled strict
`TextGrammar`, failing the live request with HTTP 500.
Before this change, `TmlOutput::call` parsed `{"name", "args"}` into
`serde_json::Value` and emitted `args.to_string()`. After this change,
`TmlOutput::call` deserializes the wrapper into a `#[serde(deny_unknown_fields)]`
struct carrying `name: String` and `args: &'a serde_json::value::RawValue`,
verifies that the raw slice starts with `{`, and emits the exact JSON object
text verbatim. Duplicate wrapper keys and unknown wrapper keys are rejected
and surfaced as visible text, matching prior TMLv0 recovery semantics. Added
`call_preserves_raw_json_arguments_including_arbitrary_precision_integers` in
`helios/src/output/tml.rs`, `tml_strict_parser_preserves_30_digit_integers` in
`helios/src/grammar/strict.rs`, and `test_strict_tml_tool_calls_and_truncation`
in `tests/server/test_inkling2.py`.
Strict TMLv0 function calls now preserve arbitrary-precision integers and exact
JSON argument text from constrained decoding through `TmlOutput` and
`OutputEncoder` validation, matching the raw-token preservation already used by
the Qwen, GLM, and DeepSeek DSML parsers. No model core re-export or wire
format change is required.
Evidence: on `dgx2` (NVIDIA GB10 ARM64), `cargo test --locked --release
--manifest-path helios/Cargo.toml --features runtime-core,server` passed all
7 `output::tml::` tests, all 28 active `grammar::strict::` tests (1 ignored
DeepSeek checkpoint fixture), both `server::protocol::tests::strict` tests, and
all 5 `server::request::tml_tests::` tests against the Inkling 2 checkpoint
tokenizer. Live 4-Spark TP4 serving verification on Inkling 2 Small NVFP4
follows in deployment.
Discord: woooflet
Design-Signed-Off-By: Antigravity (Gemini-4-Neon); design-review=2e5b
Signed-off-by: woooflet <ford@fordmorris.com>
|
Rebased onto latest
Discord: woooflet |
c7fae93 to
a0d9065
Compare
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Ready To MergeFixes a real, reproducible HTTP 500 still live on
Walkthrough
Merge Risk: Low · up to
|
… ToolParser Why: Commit 905aa6e (#575) added the unit test `tml_strict_parser_preserves_30_digit_integers` in `helios/src/grammar/strict.rs` constructing `contract::ToolParser` without the `open` and `close` fields added by 2acc3f3 (#670). As a result, compiling `flare-helios` unit tests failed with `error[E0063]: missing fields close and open in initializer of contract::ToolParser`. What changed: Added `open: String::new()` and `close: String::new()` to the `ToolParser` initializer in `tml_strict_parser_preserves_30_digit_integers` in `helios/src/grammar/strict.rs`, matching the other `ToolParser` test literals in the module. No production code changed. Claimed result: Restores `flare-helios` unit-test compilation and exercises `tml_strict_parser_preserves_30_digit_integers` without altering runtime behavior. Supporting evidence (Linux x86_64 CPU): - `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib -- grammar::strict::`: 28 passed, 0 failed, 1 ignored (`ds41_checkpoint_strict_dsml_fixture_replays_complete_masks`, requires `FLARE_DEEPSEEK_TEST_SNAPSHOT`). Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b Signed-off-by: Luke Alonso <lalonso@gmail.com>
Why
For
ToolParserKind::TmlJson(Inkling 2) withstrict: trueschemas containing unbounded"type": "integer"fields,TmlOutput::call(helios/src/output/tml.rs) previously round-trippedargsthroughserde_json::Value(args.to_string()). Withoutarbitrary_precision, integers aboveu64::MAX(e.g., 30-digit IDs) silently rounded to binary64 scientific notation, failingOutputEncoder's strictTextGrammarvalidation with HTTP 500 (tracked indocs/TODO.txt).What Changed
helios/src/output/tml.rs: deserialize{"name", "args"}into a#[serde(deny_unknown_fields)]struct carrying#[serde(borrow)] args: &'a RawValue, checkargs.trim().starts_with('{'), and emit the raw JSON object text verbatim (matching Qwen, GLM, and DeepSeek DSML raw-token preservation). Note: this also passes non-strict TMLv0argsverbatim without serde re-serialization and rejects duplicate wrapper keys as visible text.helios/src/output/tml.rs,helios/src/grammar/strict.rs,tests/server/test_inkling2.py: add Rust unit tests for 30-digit integers and duplicate wrapper keys, plus a live strict-tool/truncation server test.Benefit & Evidence
cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server(output::tml::,grammar::strict::,server::protocol::tests::strict,server::request::tml_tests::all passing) and live 4-Spark TP4 Inkling 2 Small strict tool-calling qualification.Caveats: Qualified live on Inkling 2 Small NVFP4 (4× GB10 ARM64 TP4). Non-strict TMLv0 calls now also forward raw
argstext verbatim, and duplicate wrapper keys fall back to visible text. Non-TML tool parsers are untouched.Discord: woooflet