[Bugfix] Add Kimi-K2.5 reasoning/tool parser aliases and tool_call_id support (#37438)

Signed-off-by: DorBernsohn <dor.bernsohn@gmail.com>
This commit is contained in:
DorBernsohn
2026-03-19 21:08:00 +08:00
committed by GitHub
parent a32eaf5bb2
commit c63ca2b2e6
4 changed files with 173 additions and 18 deletions
+14
View File
@@ -1660,6 +1660,20 @@ def get_history_tool_calls_cnt(conversation: list[ConversationMessage]):
return idx
_KIMI_MODEL_TYPES = ("kimi_k2", "kimi_k25")
def get_tool_call_id_type(model_config: ModelConfig) -> str:
"""Return the tool-call ID type for a given model configuration."""
hf_overrides = getattr(model_config, "hf_overrides", None)
if model_config.hf_text_config.model_type in _KIMI_MODEL_TYPES or (
isinstance(hf_overrides, dict)
and hf_overrides.get("model_type") in _KIMI_MODEL_TYPES
):
return "kimi_k2"
return "random"
def make_tool_call_id(id_type: str = "random", func_name=None, idx=None):
if id_type == "kimi_k2":
return f"functions.{func_name}:{idx}"
@@ -19,6 +19,7 @@ from vllm.entrypoints.chat_utils import (
ChatTemplateContentFormatOption,
ConversationMessage,
get_history_tool_calls_cnt,
get_tool_call_id_type,
make_tool_call_id,
)
from vllm.entrypoints.logger import RequestLogger
@@ -152,15 +153,7 @@ class OpenAIServingChat(OpenAIServing):
get_stop_tokens_for_assistant_actions()
)
# Handle tool call ID type for Kimi K2 (supporting test mocking via overrides)
hf_overrides = getattr(self.model_config, "hf_overrides", None)
if self.model_config.hf_text_config.model_type == "kimi_k2" or (
isinstance(hf_overrides, dict)
and hf_overrides.get("model_type") == "kimi_k2"
):
self.tool_call_id_type = "kimi_k2"
else:
self.tool_call_id_type = "random"
self.tool_call_id_type = get_tool_call_id_type(self.model_config)
# NOTE(woosuk): While OpenAI's chat completion API supports browsing
# for some models, currently vLLM doesn't support it. Please use the
+2 -9
View File
@@ -46,6 +46,7 @@ from vllm.engine.protocol import EngineClient
from vllm.entrypoints.chat_utils import (
ChatCompletionMessageParam,
ChatTemplateContentFormatOption,
get_tool_call_id_type,
)
from vllm.entrypoints.logger import RequestLogger
from vllm.entrypoints.mcp.tool_server import ToolServer
@@ -241,15 +242,7 @@ class OpenAIServingResponses(OpenAIServing):
get_stop_tokens_for_assistant_actions()
)
# Handle tool call ID type for Kimi K2 (supporting test mocking via overrides)
hf_overrides = getattr(self.model_config, "hf_overrides", None)
if self.model_config.hf_text_config.model_type == "kimi_k2" or (
isinstance(hf_overrides, dict)
and hf_overrides.get("model_type") == "kimi_k2"
):
self.tool_call_id_type = "kimi_k2"
else:
self.tool_call_id_type = "random"
self.tool_call_id_type = get_tool_call_id_type(self.model_config)
self.enable_auto_tools = enable_auto_tools
# HACK(woosuk): This is a hack. We should use a better store.