[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
+18
View File
@@ -2,6 +2,7 @@ import os
import subprocess
import warnings
from contextlib import ExitStack, contextmanager
from enum import IntEnum
from typing import Any
@@ -105,6 +106,20 @@ class EnvFloat(EnvField):
raise ValueError(f'"{value}" is not a valid float value')
class ToolStrictLevel(IntEnum):
"""
Defines the strictness levels for tool call parsing and validation.
OFF: No strict validation
FUNCTION: Enables structural tag constraints for all tools
PARAMETER: Enforces strict parameter validation for all tools
"""
OFF = 0
FUNCTION = 1
PARAMETER = 2
class Envs:
# fmt: off
@@ -259,6 +274,9 @@ class Envs:
# Sparse Embeddings
SGLANG_EMBEDDINGS_SPARSE_HEAD = EnvStr(None)
# Tool-Call behavior
SGLANG_TOOL_STRICT_LEVEL = EnvInt(ToolStrictLevel.OFF)
# fmt: on