From f3656432c7a365c9e678f5f2dd02d9acb05437fb Mon Sep 17 00:00:00 2001 From: Hudson Xing <1277646412@qq.com> Date: Thu, 12 Feb 2026 03:28:05 -0800 Subject: [PATCH] add tool_choice=auto nightly test case (#18302) --- python/sglang/test/tool_call_test_runner.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/python/sglang/test/tool_call_test_runner.py b/python/sglang/test/tool_call_test_runner.py index 1344fce9c..494595e9c 100644 --- a/python/sglang/test/tool_call_test_runner.py +++ b/python/sglang/test/tool_call_test_runner.py @@ -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"),