Repository navigation
fix(server): keep '/' in MiniMax M3 tool-call tag names - #3741
Conversation
368a9b0 to
65f9e9b
Compare
65f9e9b to
2eb860e
Compare
A parser-level test for the slash-keeping tag names: an invoke to an undeclared tool whose body uses a slashed key is still dropped with an `unknown tool` error (the lablup#3690 reporting path), and a `<x/>` tag or an unclosed slashed key absorbs only the rest of its own invoke body, so the enclosing `</invoke>` is still found and the following invokes parse intact. Refs lablup#3738
Maintainer hardening reviewReviewed against #3738. The one-line change in Checked and found no gap:
Added (620e46c): Validation (Linux aarch64, default features): |
With lablup#3741 merged first, its port of mlx-vlm's test_object_keys_with_json_legal_punctuation_are_kept now uses upstream's value `true`, expecting the string "true" for all four keys under a tool schema. That covers the one-key test added here, so it is dropped. Add minimax_m3_client_schema_walk_is_bounded: a 60-level anyOf nest parsed through serde_json (the request-body nesting limit is what bounds the new schema-kind recursion) still keeps the item list in schema context, and a self-referential `$ref` is never resolved, so its leaves take the schema-less rule (as in mlx-vlm and vLLM). Refs lablup#3739, lablup#3754
…ol schema (#3754) * fix(server): keep schema-less MiniMax M3 leaves as strings under a tool schema mlx-vlm's MiniMax M3 parser reads a leaf that has no schema of its own in "schema context" once the request declares tools: it stays the string the model wrote, except `null`. Without tools it is JSON-decoded and otherwise kept as written. mlxcel ran every such leaf through the shared loose fallback, so with tools `true`, `42` and `02134` came back as `true`, `42` and `2134` (the leading zero lost), and without tools `02134` still became `2134`. Carry mlx-vlm's `schema_context` flag down the M3 descent and read a schema-less leaf (and mixed `$text`) with an M3-only helper. As in mlx-vlm, a schema that gives no type to apply (`{}`, a description alone, `Optional[Any]`) counts as no schema, a named child falls back to an `additionalProperties` schema, and whether an `item` list keeps the context follows mlx-vlm's schema-kind inference (`Optional[list]`, `items` without `type`, `map`/`sequence`/`arr`). Leaves with a declared type and the shared fallback used by MiniMax M2, Qwen3-Coder, GLM-4.7 and LongCat are unchanged. Closes #3739. * test: use upstream value for slashed M3 keys, pin bounded schema walk With #3741 merged first, its port of mlx-vlm's test_object_keys_with_json_legal_punctuation_are_kept now uses upstream's value `true`, expecting the string "true" for all four keys under a tool schema. That covers the one-key test added here, so it is dropped. Add minimax_m3_client_schema_walk_is_bounded: a 60-level anyOf nest parsed through serde_json (the request-body nesting limit is what bounds the new schema-kind recursion) still keeps the item list in schema context, and a self-referential `$ref` is never resolved, so its leaves take the schema-less rule (as in mlx-vlm and vLLM). Refs #3739, #3754 --------- Co-authored-by: Jeongkyu Shin <[email protected]>
Summary
Closes #3738.
The MiniMax M3 tool-call parser ended a tag name at
/. M3 writes each parameter and each nested object key as its own namespaced element, so the tag name is a JSON object key, and keys with/are ordinary:aws:ResourceTag/team,aws:RequestTag/${TagKey},application/json. Such a key reached the call's arguments cut at the/, and sibling keys that differ only after it folded into one array. A tag name now runs to the first whitespace or>. On well-formed tags that gives the same names as mlx-vlm after Neywa-Labs/mlx-vlm@2208690a (_TAG_NAME_RE = [^\s<>]+). Upstream applies that regex to everything between<and>and rejects the call when it does not match; this parser keeps its existing, more lenient handling of such tags (see Limits).What changed
src/server/tool_calls/formats.rs,minimax_m3_read_tag: the name terminator drops/(and the>test, which could never fire because the slice already ends before>), keeping whitespace. The doc comment states the rule, cites the upstream commit, says where the parser stays more lenient than upstream (text after whitespace in a tag), and says what happens to a trailing/:<x/>reads as the namex/, as upstream, which has no self-closing form either. Before,<x/>read asxand then looked for a</x>that does not come, so neither version gave it a self-closing meaning.minimax_m3_object_keys_keep_slash_and_punctuation: upstream's four keys (aws:SourceAccount,aws:ResourceTag/team,aws:RequestTag/${TagKey},application/json) underpolicy -> Condition -> StringEquals, with upstream's tool schema; the parsed arguments must equal the expected object exactly and carry no parse errors. The value isteam-awhere upstream's test usestrue, so the test is about the key alone and does not depend on how a leaf with no schema of its own is read (upstream expects the string"true"; that reading is tracked in fix(server): MiniMax M3 coerces schema-less tool-call leaves that mlx-vlm keeps as strings, dropping leading zeros #3739, see Limits). The test's doc comment says so.minimax_m3_slashed_keys_are_distinct_fold_and_end_at_whitespace: siblingsaws:ResourceTag,aws:ResourceTag/team,aws:ResourceTag/envstay three keys; a repeateda/b/cstill folds into an array; a key ending in/(path/) reads whole; whitespace still ends a name (<k/v type="s">is the keyk/v). That last case is mlxcel's existing leniency, not upstream's rule: upstream rejects<k/v type="s">(invalid tag 'k/v type="s"') and with it the whole call. The test pins the behaviourmainalready had for such a tag, and its comments say it is mlxcel-only.src/server/tool_calls/stream_parity_tests.rs,minimax_m3_slashed_object_keys_parse_the_same_streamed: three slashed keys throughassert_parity, which compares the streamed path (every byte-boundary chunking, plus widths 1, 2, 3, 5 and 7) with the non-streamed parse, then checks the arguments. The stream filter has no tag scan of its own (it suppresses the namespaced block and hands the text totry_minimax_m3), so the fix reaches both paths through this one function.Other callers:
minimax_m3_read_tagis private and called only byminimax_m3_find_closeandminimax_m3_scan_children; the<invoke name=...>opener is parsed separately and is unchanged. MiniMax M2, Qwen3-Coder, GLM-4.7 and LongCat use other grammars and only share the schema helpers, which this does not touch.Complexity: unchanged; the name scan is still one pass over the tag.
Verification
Linux 7.0.0-1019-nvidia aarch64 (NVIDIA GB10, CUDA 13.0.88), rustc 1.97.1,
--features cuda,--profile test-fast. Base9402cf893. Commit treeb1674fab, which differs from tree77d718beonly inCHANGELOG.md(an entry since removed). The tests and checks below ran on tree955138da, which differs from77d718beonly in comments (///and//lines insrc/server/tool_calls/formats.rs) and one CHANGELOG sentence (git diff 955138da 77d718be);cargo fmt --check, clippy and thetool_calls::tests were re-run ondc7ae92d, andcargo fmt --checkand thetool_calls::tests again on77d718be(it differs fromdc7ae92din one doc comment).Tests
cargo test --locked --profile test-fast --features cuda --lib -- --test-threads=1 tool_calls::. Themainarm ismainplus the three new tests, with only the one-line fix inminimax_m3_read_tagreverted.main+ the new testsformats::tests::minimax_m3_object_keys_keep_slash_and_punctuationaws:ResourceTag/teamgives{"policy": {"Condition": {"StringEquals": {"aws:ResourceTag": "team-a"}}}}formats::tests::minimax_m3_slashed_keys_are_distinct_fold_and_end_at_whitespace{"aws:ResourceTag": ["base", "a", "prod"], "a": ["x", "y"], "path": "p"}stream_filter::stream_parity_tests::minimax_m3_slashed_object_keys_parse_the_same_streamedaws:ResourceTag,aws:RequestTag,application(streamed and non-streamed agree; both cut)tool_calls::totalRe-run on tree
dc7ae92d: 572 passed, 0 failed. Re-run on tree77d718be: 572 passed, 0 failed.Checks
cargo fmt --all -- --checkcargo clippy --locked --workspace --all-targets --features cuda -- -D warningspython3 scripts/ci/check_used_by.py(used-by: OK, 78 top-level pub fn in 2 shared files, 57 annotated, 715 caller-file references resolved, 3498 Rust files scanned),bash scripts/ci/check_used_by_test.sh(all cases passed)make verify-test-cuda, tree955138dabefore and after: 18,894 passed, 2 failed, 578 ignored over 207test resultlines. Both failures were pre-existing on the base9402cf893and are unrelated to this change; currentmainfixes both (feat(speculative): add DeepSeek-V4.1 bundled DSpark drafter (#3262) #3686, test: restore MLX guard scan and no-GPU catalog test gates #3765):tests/mlx_test_guard_coverage.rsmlx_evaluating_lib_tests_take_mlx_test_guard:src/vision/encoders/nemotron_h_nano_omni_tests.rs:276 pos_embed_resample_runs_in_f32evaluates MLX without the guard. The new tests here evaluate no MLX arrays and are not listed.tests/step3p7_parity.rstext_decode_delegates_sequence_local_native_batching:assertion failed: !wrapper.supports_padded_prefill().On unmodified
main(9402cf893),cargo test --locked --profile test-fast --features cuda --test mlx_test_guard_coverage --test step3p7_parity -- --test-threads=1fails both the same way (5 passed / 1 failed and 7 passed / 1 failed, same messages).git merge-treemerges the commit onto currentorigin/main(5bf7b8628) without conflict. On the merged tree, the Python tooling tests (python3 -m unittest discover -s tests -p 'test_*.py'), thescripts/cichecks CI runs andcargo fmt --all -- --checkpass.Model run
No model run. The smallest MLX conversion in the family I found is
mlx-community/MiniMax-M3.1-Flash-Text-3bitat 186.5 GB (MiniMaxAI/MiniMax-M3is 854 GB,mlx-community/MiniMax-M3-4bit241.5 GB), which does not fit a 121 GB GB10. The parser takes text and returns JSON, so the unit and stream-parity tests drive the whole changed path.Limits
[^\s<>]+against the whole text between<and>and raises for a tag such as<k/v type="s">, failing the call. mlxcel ends the name at the first whitespace and ignores the rest, asmainalready did. Not changed here."true","42","02134"); that is tracked in fix(server): MiniMax M3 coerces schema-less tool-call leaves that mlx-vlm keeps as strings, dropping leading zeros #3739 and fixed by fix(server): keep schema-less MiniMax M3 leaves as strings under a tool schema #3754. The ported upstream test uses the valueteam-ainstead oftrueso that it does not depend on that reading. Whichever of this PR and fix(server): keep schema-less MiniMax M3 leaves as strings under a tool schema #3754 merges second switches this test to upstream's valuetrue(expected"true").