Skip to content

Conversation

@qandrew
Copy link
Owner

@qandrew qandrew commented Oct 29, 2025

Test Plan Chat Completions

run minimax_m2.py

Test Plan Responses API

vllm serve MiniMaxAI/MiniMax-M2     --tensor-parallel-size 4     --tool-call-parser minimax_m2     --reasoning-parser minimax_m2_append_think     --enable-auto-tool-choice     --chat-template examples/tool_chat_template_minimax_m1.jinja     --port 8000
(gpt_oss_edit) [axia@devvm30969.cln0 /data/users/axia/gitrepos/vllm (func_call_2_minimax)]$ curl http://localhost:8000/v1/responses \
  -H "Content-Type: application/json" \
  -N \
  -d '{
    "model": "MiniMaxAI/MiniMax-M2",
    "input": [
      {
        "role": "user",
        "content": "What is the horoscope for Leo today?"
      }
    ],
    "tools": [
      {
        "type": "custom",
        "name": "get_horoscope",
        "description": "Get today’s horoscope for an astrological sign.",
        "parameters": {
          "type": "object",
          "properties": {
            "sign": {
              "type": "string",
              "description": "Astrological sign, e.g. Aries, Taurus, Gemini, etc."
            }
          },
          "required": ["sign"]
        }
      }
    ],
    "temperature": 0.7,
    "max_output_tokens": 256
  }'

output

{
    "id": "resp_7ac22ac8a43e4d619435faf74ea3f3e2",
    "created_at": 1761772334,
    "incomplete_details": null,
    "instructions": null,
    "metadata": null,
    "model": "MiniMaxAI/MiniMax-M2",
    "object": "response",
    "output": [
        {
            "id": "msg_c9dac216687f4847bbd75fa7daf567a2",
            "content": [
                {
                    "annotations": [],
                    "text": "<think><think>\nAlright, the user is asking for the horoscope for Leo today. This is a straightforward request that I can fulfill using the tools available to me.\n\nLooking at my tools, I have access to a \"get_horoscope\" tool that can provide today's horoscope for an astrological sign. This is exactly what I need for this request.\n\nThe tool requires a parameter called \"sign\" which should be the astrological sign the user is interested in. In this case, the user specifically asked for Leo, so I'll need to pass \"Leo\" as the sign parameter.\n\nThe format for the tool call is to use the <tool_calls></tool_calls> XML tags and provide a JSON object with the tool name and arguments. For this case, I'll need:\n- name: \"get_horoscope\"\n- arguments: {\"sign\": \"Leo\"}\n\nThis should retrieve today's horoscope for Leo, which is what the user is asking for. I don't need to provide any additional information or clarification since the request is clear and specific.\n\nOnce I make this tool call, the system will return the horoscope information for Leo today, which I can then present to the user. Since this is a simple factual query that can be answered directly by the tool, I don't need to provide any additional context or explanation beyond what the tool returns.\n\nI'll go ahead and make the tool call to get the horoscope for Leo today.\n</think>\n\n<tool_calls>\n{\"name\": \"get_horoscope\", \"arguments\": {\"sign\": \"Leo\"}}\n</tool_calls>",
                    "type": "output_text",
                    "logprobs": null
                }
            ],
            "role": "assistant",
            "status": "completed",
            "type": "message"
        }
    ],
    "parallel_tool_calls": true,
    "temperature": 0.7,
    "tool_choice": "auto",
    "tools": [
        {
            "name": "get_horoscope",
            "type": "custom",
            "description": "Get today’s horoscope for an astrological sign.",
            "format": null,
            "parameters": {
                "type": "object",
                "properties": {
                    "sign": {
                        "type": "string",
                        "description": "Astrological sign, e.g. Aries, Taurus, Gemini, etc."
                    }
                },
                "required": [
                    "sign"
                ]
            }
        }
    ],
    "top_p": 0.95,
    "background": false,
    "max_output_tokens": 1000,
    "max_tool_calls": null,
    "previous_response_id": null,
    "prompt": null,
    "reasoning": null,
    "service_tier": "auto",
    "status": "completed",
    "text": null,
    "top_logprobs": null,
    "truncation": "disabled",
    "usage": {
        "input_tokens": 246,
        "input_tokens_details": {
            "cached_tokens": 240,
            "input_tokens_per_turn": [],
            "cached_tokens_per_turn": []
        },
        "output_tokens": 316,
        "output_tokens_details": {
            "reasoning_tokens": 0,
            "tool_output_tokens": 0,
            "output_tokens_per_turn": [],
            "tool_output_tokens_per_turn": []
        },
        "total_tokens": 562
    },
    "user": null,
    "input_messages": null,
    "output_messages": null
}

Andrew Xia added 3 commits October 29, 2025 12:18
Signed-off-by: Andrew Xia <axia@fb.com>
Signed-off-by: Andrew Xia <axia@fb.com>
Signed-off-by: Andrew Xia <axia@fb.com>
end_idx = match.end()
before = model_output[:end_idx]
after = model_output[end_idx:]
return before.strip(), after.strip()
Copy link
Owner Author

Choose a reason for hiding this comment

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

this makes the result

"output": [
        {
            "id": "rs_3f8177bfe6964ad896e3b092f5831839",
            "summary": [],
            "type": "reasoning",
            "content": [
                {
                    "text": "<think>\nLet me analyze this request. The user is asking for today's horoscope for Leo, which is one of the astrological signs. This is a straightforward request that requires me to retrieve astrological information.\n\nLooking at the tools available to me, I see I have access to a \"get_horoscope\" tool that can fetch today's horoscope for a specific astrological sign. This is exactly what I need for this request.\n\nThe tool requires a parameter called \"sign\" which should be the astrological sign. In this case, the user has specifically asked for Leo, so I'll need to pass \"Leo\" as the argument.\n\nThe format for calling this tool is to use the <tool_calls></tool_calls> XML tags and provide a JSON object with the tool name and arguments. For this case, I need to:\n1. Set the tool name as \"get_horoscope\"\n2. Set the arguments as a JSON object with the \"sign\" parameter set to \"Leo\"\n\nThis should retrieve today's horoscope for Leo, which is exactly what the user requested. The tool will handle the actual fetching of the horoscope information, and I'll receive the results to share with the user.\n\nI don't need to do any additional processing or formatting at this point - I just need to make the tool call with the correct parameters. Once I get the results back from the tool, I can then present the horoscope information to the user in a clear and helpful way.\n\nSo I'll proceed with calling the get_horoscope tool with the sign parameter set to \"Leo\".\n</think>",
                    "type": "reasoning_text"
                }
            ],
            "encrypted_content": null,
            "status": null
        },
        {
            "id": "msg_78e7fc9753fd45edab0058b6f6db62a0",
            "content": [
                {
                    "annotations": [],
                    "text": "<tool_calls>\n{\"name\": \"get_horoscope\", \"arguments\": {\"sign\": \"Leo\"}}\n</tool_calls>",
                    "type": "output_text",
                    "logprobs": null
                }
            ],
            "role": "assistant",
            "status": "completed",
            "type": "message"
        }
    ],

Signed-off-by: Andrew Xia <axia@fb.com>
"output": str(result),
}
)
response_2 = client.responses.create(
Copy link
Owner Author

Choose a reason for hiding this comment

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

running this function we get

(gpt_oss_edit) [axia@devvm30969.cln0 /data/users/axia/gitrepos/vllm (func_call_2_minimax)]$ python examples/online_serving/openai_responses_client_with_tools.py
Response(id='resp_abdcfaa50f8d49b6b16d9ef2b8cd9cff', created_at=1761777495.0, error=None, incomplete_details=None, instructions=None, metadata=None, model='MiniMaxAI/MiniMax-M2', object='response', output=[ResponseReasoningItem(id='rs_6eb70941879e43c2b2cf00deb4caea6a', summary=[], type='reasoning', content=[Content(text='<think>\nAlright, the user is asking for today\'s horoscope for Leo. This is a straightforward request that I can fulfill using the tools provided to me.\n\nLooking at the available tools, I see I have access to "get_horoscope" which is perfect for this request. The tool requires a "sign" parameter, which should be the astrological sign. In this case, the user specifically mentioned "Leo," so I\'ll use that as the parameter value.\n\nThe tool description shows it takes a JSON object with a "sign" property, which expects a string value like "Aries, Taurus, Gemini, etc." Since the user asked about Leo, I\'ll pass "Leo" as the value.\n\nI need to format my response using the specific XML tags mentioned in the system instructions: <tool_calls> and </tool_calls>. Inside these tags, I\'ll provide a JSON object with the tool name and arguments.\n\nSo my response should be:\n{"name": "get_horoscope", "arguments": {"sign": "Leo"}}\n\nThis will invoke the get_horoscope tool with Leo as the sign parameter, which should return today\'s horoscope for Leo. The tool will handle the actual fetching of the horoscope data, and once it returns the result, I\'ll be able to provide the user with Leo\'s horoscope for today.\n\nThis is the most direct way to answer the user\'s question using the available tools. No additional explanation is needed in my tool call - just the proper invocation of the get_horoscope function with Leo as the sign.\n</think>', type='reasoning_text')], encrypted_content=None, status=None), ResponseFunctionToolCall(arguments='{"sign": "Leo"}', call_id='call_d1e46e303a1e459997681473f06023d2', name='get_horoscope', type='function_call', id='fc_63dadbbaa8604ba2a4bf864fffb63354', status='completed')], parallel_tool_calls=True, temperature=1.0, tool_choice='auto', tools=[CustomTool(name='get_horoscope', type='custom', description='Get today’s horoscope for an astrological sign.', format=None, parameters={'type': 'object', 'properties': {'sign': {'type': 'string', 'description': 'Astrological sign, e.g. Aries, Taurus, Gemini, etc.'}}, 'required': ['sign']})], top_p=0.95, background=False, conversation=None, max_output_tokens=196362, max_tool_calls=None, previous_response_id=None, prompt=None, prompt_cache_key=None, reasoning=None, safety_identifier=None, service_tier='auto', status='completed', text=None, top_logprobs=None, truncation='disabled', usage=ResponseUsage(input_tokens=246, input_tokens_details=InputTokensDetails(cached_tokens=240, input_tokens_per_turn=[], cached_tokens_per_turn=[]), output_tokens=341, output_tokens_details=OutputTokensDetails(reasoning_tokens=0, tool_output_tokens=0, output_tokens_per_turn=[], tool_output_tokens_per_turn=[]), total_tokens=587), user=None, input_messages=None, output_messages=None)
Function call: get_horoscope {"sign": "Leo"}
Based on the horoscope for Leo, on the coming Tuesday you will befriend a baby otter.

note the last line receives the function call multi turn

@qandrew qandrew changed the title Func call 2 minimax WIP WIP function calls on minimax m2 Oct 29, 2025
Signed-off-by: Andrew Xia <axia@fb.com>
@qandrew qandrew changed the title WIP function calls on minimax m2 [1] function calls on minimax m2 Oct 31, 2025
@qandrew qandrew changed the base branch from main to func_call_2 November 3, 2025 18:09
Andrew Xia added 2 commits November 3, 2025 10:20
Signed-off-by: Andrew Xia <axia@fb.com>
Signed-off-by: Andrew Xia <axia@fb.com>

logger = init_logger(__name__)

def convert_tool_schema(tool: dict) -> dict:
Copy link
Owner Author

Choose a reason for hiding this comment

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

with this

vllm serve MiniMaxAI/MiniMax-M2 --tensor-parallel-size 4 --tool-call-parser minimax_m2 --reasoning-parser minimax_m2_append_think --enable-auto-tool-choice --port 8000

(gpt_oss_edit) [axia@devvm30969.cln0 /data/users/axia/gitrepos/vllm (af1965f4)]$ curl -X POST "http://localhost:8000/v1/responses"   -H "Content-Type: application/json"   -H "Authorization: Bearer dummy-api-key"   -d '{
        "model": "MiniMaxAI/MiniMax-M2",
        "input": "Whats the weather like in San Francisco? use celsius.",
        "tools": [{
            "type": "function",
            "name": "get_weather",
            "description": "Get the current weather in a given location",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string"},
                    "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
                },
                "required": ["location", "unit"]
            }
        }]
      }'
{
    "id": "resp_1258a78c6613423e89925bce8d31c40a",
    "created_at": 1762195579,
    "incomplete_details": null,
    "instructions": null,
    "metadata": null,
    "model": "MiniMaxAI/MiniMax-M2",
    "object": "response",
    "output": [
        {
            "id": "rs_5db4414970f74f2092d7062d18240b4c",
            "summary": [],
            "type": "reasoning",
            "content": [
                {
                    "text": "Okay, let's analyze what the user is asking for. They want to know about the weather in San Francisco and specifically requested the temperature in Celsius. This is a straightforward request that requires me to use one of my available tools.\n\nLooking at my available tools, I have \"get_weather\" which is perfect for this situation. The tool requires two parameters:\n1. \"location\" - which should be a string representing the place\n2. \"unit\" - which can be either \"celsius\" or \"fahrenheit\"\n\nThe user has clearly specified both parameters:\n- Location: San Francisco\n- Unit: celsius\n\nI need to format my response using the tool_calls format as specified in my instructions. The format requires me to include the tool name and a JSON object with the arguments.\n\nSo I'll need to call the get_weather tool with location=\"San Francisco\" and unit=\"celsius\". This should retrieve the current weather information for San Francisco with the temperature displayed in Celsius as requested.\n\nI notice the user didn't ask for any specific weather details beyond the general conditions, so I'll just call the basic weather tool. If they want more specific information after seeing the initial results, they can ask in a follow-up message.\n\nLet me prepare the proper tool call with these parameters.\n</think>",
                    "type": "reasoning_text"
                }
            ],
            "encrypted_content": null,
            "status": null
        },
        {
            "arguments": "{\"location\": \"San Francisco\", \"unit\": \"celsius\"}",
            "call_id": "call_b3b27bb9b8f249cda223aba574f583ac",
            "name": "get_weather",
            "type": "function_call",
            "id": "fc_68ca0384b1a54c36bc06cf8f834beeda",
            "status": "completed"
        }
    ],
    "parallel_tool_calls": true,
    "temperature": 1.0,
    "tool_choice": "auto",
    "tools": [
        {
            "name": "get_weather",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string"
                    },
                    "unit": {
                        "type": "string",
                        "enum": [
                            "celsius",
                            "fahrenheit"
                        ]
                    }
                },
                "required": [
                    "location",
                    "unit"
                ]
            },
            "strict": null,
            "type": "function",
            "description": "Get the current weather in a given location"
        }
    ],
    "top_p": 0.95,
    "background": false,
    "max_output_tokens": 196394,
    "max_tool_calls": null,
    "previous_response_id": null,
    "prompt": null,
    "reasoning": null,
    "service_tier": "auto",
    "status": "completed",
    "text": null,
    "top_logprobs": null,
    "truncation": "disabled",
    "usage": {
        "input_tokens": 214,
        "input_tokens_details": {
            "cached_tokens": 0,
            "input_tokens_per_turn": [],
            "cached_tokens_per_turn": []
        },
        "output_tokens": 296,
        "output_tokens_details": {
            "reasoning_tokens": 0,
            "tool_output_tokens": 0,
            "output_tokens_per_turn": [],
            "tool_output_tokens_per_turn": []
        },
        "total_tokens": 510
    },
    "user": null,
    "input_messages": null,
    "output_messages": null
}

Signed-off-by: Andrew Xia <axia@fb.com>
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.

2 participants