Repository navigation
fix(server): keep '/' in MiniMax M3 tool-call tag names - #3741
Open
Jaeyeong-CHOI wants to merge 1 commit into
Open
Jaeyeong-CHOI wants to merge 1 commit into
Jaeyeong-CHOI wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: upstream keeps a leaf with no schema of its own as the string"true"once the call has a tool schema, while mlxcel decodes it to the booleantrue. That is a separate difference, not changed here (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.CHANGELOG.md:## [Unreleased]/### Fixedentry.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 treedc7ae92d. The tests and checks below ran on tree955138da, which differs fromdc7ae92donly in comments (///and//lines insrc/server/tool_calls/formats.rs) and one CHANGELOG sentence (git diff 955138da dc7ae92d);cargo fmt --check, clippy and thetool_calls::tests were re-run ondc7ae92d.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 the commit's tree
dc7ae92d: 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 are onmainalready and unrelated to this change; test: fix two stale tests that keep make verify-test red #3720 fixes both: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(9402cf893) without conflict.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"); mlxcel's shared fallback decodes it (true,42,2134). This is why the ported upstream test uses the valueteam-ainstead oftrue. Reported separately in fix(server): MiniMax M3 tool calls decode schema-less leaves that mlx-vlm keeps as strings, dropping leading zeros #3739.