add tool_choice=auto nightly test case (#18302)

This commit is contained in:
Hudson Xing
2026-02-12 03:28:05 -08:00
committed by GitHub
parent e20e6c28b9
commit f3656432c7

View File

@@ -16,6 +16,7 @@ from sglang.test.test_utils import (
@dataclass
class ToolCallTestParams:
test_basic: bool = True
test_auto: bool = True
test_streaming: bool = True
test_required: bool = True
test_none: bool = True
@@ -104,6 +105,15 @@ def _test_basic_format(client, model):
assert response.choices[0].finish_reason == "tool_calls"
def _test_auto(client, model):
"""tool_choice=auto should populate tool_calls, not content (#17942)."""
response = _call(client, model, "Compute 3 + 5", tool_choice="auto")
msg = response.choices[0].message
assert msg.tool_calls and len(msg.tool_calls) > 0
assert not msg.content, f"content should be empty, got: {msg.content}"
assert response.choices[0].finish_reason == "tool_calls"
def _test_streaming(client, model):
"""Streaming chunks should concatenate to valid JSON."""
response = _call(client, model, "Compute 5 + 7", stream=True)
@@ -294,6 +304,7 @@ def _test_streaming_parallel(client, model):
_TESTS = [
("basic_format", _test_basic_format, "test_basic"),
("auto", _test_auto, "test_auto"),
("streaming", _test_streaming, "test_streaming"),
("required", _test_required, "test_required"),
("none", _test_none, "test_none"),