[feat] Add SGLANG_TOOL_STRICT_LEVEL for tool-call behavior control (#12423)

Signed-off-by: Xinyuan Tong <xinyuantong.cs@gmail.com>
This commit is contained in:
Xinyuan Tong
2025-11-01 13:15:02 -07:00
committed by GitHub
parent 2b7bf11bd2
commit d2a8f71c2f
4 changed files with 38 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ from typing import Dict, List, Literal, Optional, Union
import orjson
from sglang.srt.connector import ConnectorType
from sglang.srt.environ import envs
from sglang.srt.environ import ToolStrictLevel, envs
from sglang.srt.function_call.function_call_parser import FunctionCallParser
from sglang.srt.lora.lora_registry import LoRARef
from sglang.srt.parser.reasoning_parser import ReasoningParser
@@ -1686,6 +1686,9 @@ class ServerArgs:
os.environ["SGLANG_ENABLE_DETERMINISTIC_INFERENCE"] = (
"1" if self.enable_deterministic_inference else "0"
)
# Set the highest strict level for Kimi K2 tool calls
if self.tool_call_parser == "kimi_k2":
envs.SGLANG_TOOL_STRICT_LEVEL.set(ToolStrictLevel.PARAMETER)
def _handle_cache_compatibility(self):
if self.enable_hierarchical_cache and self.disable_radix_cache: