Skip to content

fix(server): keep '/' in MiniMax M3 tool-call tag names - #3741

Open
Jaeyeong-CHOI wants to merge 1 commit into
lablup:mainfrom
Jaeyeong-CHOI:fix/minimax-m3-tool-keys-with-slash
Open

Jaeyeong-CHOI wants to merge 1 commit into
lablup:mainfrom
Jaeyeong-CHOI:fix/minimax-m3-tool-keys-with-slash

Conversation

@Jaeyeong-CHOI

Copy link
Copy Markdown
Contributor

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 name x/, as upstream, which has no self-closing form either. Before, <x/> read as x and then looked for a </x> that does not come, so neither version gave it a self-closing meaning.
  • Tests in the same file:
    • minimax_m3_object_keys_keep_slash_and_punctuation: upstream's four keys (aws:SourceAccount, aws:ResourceTag/team, aws:RequestTag/${TagKey}, application/json) under policy -> Condition -> StringEquals, with upstream's tool schema; the parsed arguments must equal the expected object exactly and carry no parse errors. The value is team-a where upstream's test uses true: 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 boolean true. 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: siblings aws:ResourceTag, aws:ResourceTag/team, aws:ResourceTag/env stay three keys; a repeated a/b/c still folds into an array; a key ending in / (path/) reads whole; whitespace still ends a name (<k/v type="s"> is the key k/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 behaviour main already 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 through assert_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 to try_minimax_m3), so the fix reaches both paths through this one function.
  • CHANGELOG.md: ## [Unreleased] / ### Fixed entry.

Other callers: minimax_m3_read_tag is private and called only by minimax_m3_find_close and minimax_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. Base 9402cf893. Commit tree dc7ae92d. The tests and checks below ran on tree 955138da, which differs from dc7ae92d only in comments (/// and // lines in src/server/tool_calls/formats.rs) and one CHANGELOG sentence (git diff 955138da dc7ae92d); cargo fmt --check, clippy and the tool_calls:: tests were re-run on dc7ae92d.

Tests

cargo test --locked --profile test-fast --features cuda --lib -- --test-threads=1 tool_calls::. The main arm is main plus the three new tests, with only the one-line fix in minimax_m3_read_tag reverted.

main + the new tests fix
formats::tests::minimax_m3_object_keys_keep_slash_and_punctuation FAIL: aws:ResourceTag/team gives {"policy": {"Condition": {"StringEquals": {"aws:ResourceTag": "team-a"}}}} pass
formats::tests::minimax_m3_slashed_keys_are_distinct_fold_and_end_at_whitespace FAIL: {"aws:ResourceTag": ["base", "a", "prod"], "a": ["x", "y"], "path": "p"} pass
stream_filter::stream_parity_tests::minimax_m3_slashed_object_keys_parse_the_same_streamed FAIL: keys aws:ResourceTag, aws:RequestTag, application (streamed and non-streamed agree; both cut) pass
tool_calls:: total 569 passed, 3 failed 572 passed, 0 failed

Re-run on the commit's tree dc7ae92d: 572 passed, 0 failed.

Checks

  • cargo fmt --all -- --check
  • cargo clippy --locked --workspace --all-targets --features cuda -- -D warnings
  • python3 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, tree 955138da before and after: 18,894 passed, 2 failed, 578 ignored over 207 test result lines. Both failures are on main already and unrelated to this change; test: fix two stale tests that keep make verify-test red #3720 fixes both:
    • tests/mlx_test_guard_coverage.rs mlx_evaluating_lib_tests_take_mlx_test_guard: src/vision/encoders/nemotron_h_nano_omni_tests.rs:276 pos_embed_resample_runs_in_f32 evaluates MLX without the guard. The new tests here evaluate no MLX arrays and are not listed.
    • tests/step3p7_parity.rs text_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=1 fails both the same way (5 passed / 1 failed and 7 passed / 1 failed, same messages).

git merge-tree merges the commit onto current origin/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-3bit at 186.5 GB (MiniMaxAI/MiniMax-M3 is 854 GB, mlx-community/MiniMax-M3-4bit 241.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

  • Parser tests only; no model generated these blocks (see above).
  • Not the same as upstream on malformed tags. Upstream matches [^\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, as main already did. Not changed here.
  • Not changed (follow-up): value coercion of a leaf that has no schema of its own. Once the call has a tool schema, upstream keeps such a leaf as a string ("true", "42", "02134"); mlxcel's shared fallback decodes it (true, 42, 2134). This is why the ported upstream test uses the value team-a instead of true. Reported separately in fix(server): MiniMax M3 tool calls decode schema-less leaves that mlx-vlm keeps as strings, dropping leading zeros #3739.
  • Not run on Metal.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(server): MiniMax M3 tool-call parser cuts parameter names at "/"

1 participant