From 762022cafb1afc4c51ce706c043e2f1f5826003a Mon Sep 17 00:00:00 2001 From: Chauncey Date: Wed, 29 Apr 2026 17:55:07 +0800 Subject: [PATCH] [Bugfix] DSV32/V4 add missing type conversion for non-streaming tool calls (#41198) Signed-off-by: chaunceyjiang --- .../test_deepseekv32_tool_parser.py | 24 +++++++++++++++++++ vllm/tool_parsers/deepseekv32_tool_parser.py | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/tool_parsers/test_deepseekv32_tool_parser.py b/tests/tool_parsers/test_deepseekv32_tool_parser.py index 6145253d9f..c547795e7b 100644 --- a/tests/tool_parsers/test_deepseekv32_tool_parser.py +++ b/tests/tool_parsers/test_deepseekv32_tool_parser.py @@ -188,6 +188,30 @@ class TestExtractToolCalls: "location": "NYC" } + def test_type_conversion_in_non_streaming(self): + """Non-streaming extraction must convert params using the tool schema.""" + tool = ChatCompletionToolsParam( + function=FunctionDefinition( + name="toggle", + parameters={ + "type": "object", + "properties": { + "enabled": {"type": "boolean"}, + "count": {"type": "integer"}, + }, + }, + ), + ) + parser = make_parser(tools=[tool]) + model_output = build_tool_call("toggle", {"enabled": "true", "count": "42"}) + result = parser.extract_tool_calls(model_output, None) + assert result.tools_called + assert len(result.tool_calls) == 1 + args = json.loads(result.tool_calls[0].function.arguments) + assert args == {"enabled": True, "count": 42} + assert isinstance(args["enabled"], bool) + assert isinstance(args["count"], int) + # --------------------------------------------------------------------------- # Tests: extract_tool_calls_streaming diff --git a/vllm/tool_parsers/deepseekv32_tool_parser.py b/vllm/tool_parsers/deepseekv32_tool_parser.py index b862359236..02182e2293 100644 --- a/vllm/tool_parsers/deepseekv32_tool_parser.py +++ b/vllm/tool_parsers/deepseekv32_tool_parser.py @@ -191,12 +191,13 @@ class DeepSeekV32ToolParser(ToolParser): tool_call_match ): param_dict = self._parse_invoke_params(invoke_content) + params = self._convert_params_with_schema(invoke_name, param_dict) tool_calls.append( ToolCall( type="function", function=FunctionCall( name=invoke_name, - arguments=json.dumps(param_dict, ensure_ascii=False), + arguments=json.dumps(params, ensure_ascii=False), ), ) )