Skip to content

Fix optional parameter parsing in MiniMax M2 tool parser #32278#32342

Merged
chaunceyjiang merged 1 commit intovllm-project:mainfrom
baonudesifeizhai:fixMiniMaxm2tool
Jan 15, 2026
Merged

Fix optional parameter parsing in MiniMax M2 tool parser #32278#32342
chaunceyjiang merged 1 commit intovllm-project:mainfrom
baonudesifeizhai:fixMiniMaxm2tool

Conversation

@baonudesifeizhai
Copy link
Copy Markdown
Contributor

@baonudesifeizhai baonudesifeizhai commented Jan 14, 2026

Purpose

#32278

Test Plan

 CUDA_VISIBLE_DEVICES=0,1,2,3 \
python -m vllm.entrypoints.openai.api_server \
  --model MiniMaxAI/MiniMax-M2 \
  --tensor-parallel-size 4 \
  --gpu-memory-utilization 0.90 \
  --max-model-len 32768 \
  --enable-auto-tool-choice \
  --tool-call-parser minimax_m2 \
  --trust-remote-code \
  --port 8000
curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMaxAI/MiniMax-M2",
    "messages": [{
      "role": "user",
      "content": "使用 run_shell 工具,command 参数是 date,logfile 参数必须是 /tmp/foo(不是空值)"
    }],
    "tools": [{
      "type": "function",
      "function": {
        "name": "run_shell",
        "description": "执行 shell 命令",
        "parameters": {
          "type": "object",
          "properties": {
            "command": {"type": "string"},
            "logfile": {"type": ["string", "null"]}
          },
          "required": ["command"]
        }
      }
    }],
    "tool_choice": "auto"
  }'

Test Result

main branch:
"logprobs":null,

           "command": {"type": "string"},
            "logfile": {"type": ["string", "null"]}
          },
          "required": ["command"]
        }
      }
    }],
    "tool_choice": "auto"
  }'
{"id":"chatcmpl-92af089130f8e5ad","object":"chat.completion","created":1768411489,"model":"MiniMaxAI/MiniMax-M2","choices":[{"index":0,"message":{"role":"assistant","content":"Okay, let's analyze what the user is asking. They want me to execute a shell command using the run_shell tool, and they've specified two parameters:\n1. The command to execute: \"date\" (which displays the current date and time)\n2. The log file where output should be saved: \"/tmp/foo\"\n\nLooking at the run_shell tool description in my system message, I can see it has two parameters:\n- \"command\": A string representing the shell command to execute\n- \"logfile\": A string representing the file where command output should be logged (optional)\n\nThe user has provided values for both parameters, which is good because \"command\" is required and \"logfile\" is optional but they've specified it anyway.\n\nTo execute this request, I need to format a proper tool call using the specified XML format with the tool name and JSON arguments. The tool name is \"run_shell\" and the arguments are the command and logfile parameters.\n\nI'll structure my response as a tool call with:\n- The tool name: \"run_shell\"\n- The arguments: A JSON object containing the command \"date\" and the logfile \"/tmp/foo\"\n\nThis should execute the date command and save its output to the specified log file. The date command typically outputs something like \"Thu Jun 17 14:23:45 UTC 2023\" depending on the system and date/time settings.\n\nSo I'll use the tool_calls format as instructed in my system message to make this request.\n</think>\n\n\n","refusal":null,"annotations":null,"audio":null,"function_call":null,"tool_calls":[{"id":"chatcmpl-tool-960e310b9581fec6","type":"function","function":{"name":"run_shell","arguments":"{\"command\": \"date\", \"logfile\": null}"}}],"reasoning":null,"reasoning_content":null},"logprobs":null,"finish_reason":"tool_calls","stop_reason":null,"token_ids":null}],"service_tier":null,"system_fingerprint":null,"usage":{"prompt_tokens":216,"total_tokens":558,"completion_tokens":342,"prompt_tokens_details":null},"prompt_logprobs":null,"prompt_token_ids":null,"kv_transfer_params":null}(vllm)  

image \"logfile\": \"/tmp/foo\"}" ---
Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

Signed-off-by: baonudesifeizhai <baonudesifeizhai@gmail.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a bug in the MiniMax M2 tool parser that caused optional parameters to always be parsed as null, even when a specific value was provided. The root cause was an incorrect check that verified if null was an allowed type, instead of checking if the provided value itself was a null-like string. The fix removes this erroneous logic, ensuring that optional parameters are now correctly parsed. The change is correct and effectively resolves the issue.

Copy link
Copy Markdown
Collaborator

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks~

@chaunceyjiang chaunceyjiang added the ready ONLY add when PR is ready to merge/full CI is needed label Jan 15, 2026
@chaunceyjiang chaunceyjiang enabled auto-merge (squash) January 15, 2026 02:09
@chaunceyjiang chaunceyjiang merged commit 19b251f into vllm-project:main Jan 15, 2026
51 checks passed
sammysun0711 pushed a commit to sammysun0711/vllm that referenced this pull request Jan 16, 2026
akh64bit pushed a commit to akh64bit/vllm that referenced this pull request Jan 16, 2026
dsuhinin pushed a commit to dsuhinin/vllm that referenced this pull request Jan 21, 2026
…#32278 (vllm-project#32342)

Signed-off-by: baonudesifeizhai <baonudesifeizhai@gmail.com>
Signed-off-by: dsuhinin <suhinin.dmitriy@gmail.com>
ItzDEXX pushed a commit to ItzDEXX/vllm that referenced this pull request Feb 19, 2026
bbrowning added a commit to bbrowning/vllm that referenced this pull request Mar 26, 2026
Audited recent tool parser bug-fix PRs and found that several
landed without corresponding test coverage. Added unit tests
for each fix to prevent regressions.

- Mistral: fast detokenization text detection (PR vllm-project#37209)
- Qwen3Coder: malformed XML crash, anyOf double-encoding,
  speculative decode streaming (PRs vllm-project#36774, vllm-project#36032, vllm-project#35615)
- DeepSeekV32: delimiter preservation with fast detokenization,
  skip_special_tokens adjustment (PR vllm-project#33964)
- GLM-4 MoE: zero-argument tool calls, transformers 5.x delimiter
  handling, Unicode character preservation (PRs vllm-project#32321, vllm-project#31622, vllm-project#30920)
- MiniMax M2: anyOf nullable parameter handling for non-null and
  null values (PR vllm-project#32342)
- Step3p5: MTP-style variable-chunk and multi-token streaming
  (PR vllm-project#33690)
- Kimi K2: native tool call ID extraction and multi-turn ID
  continuity (PR vllm-project#32768)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Signed-off-by: Ben Browning <bbrownin@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants