[Frontend] Skip structural tags for auto tool_choice without strict mode (#45600)

Signed-off-by: sfeng33 <4florafeng@gmail.com>
This commit is contained in:
Flora Feng
2026-06-15 19:55:31 +00:00
committed by GitHub
parent e18fe932ca
commit cd9078fe59
8 changed files with 111 additions and 24 deletions
@@ -14,6 +14,7 @@ from vllm.entrypoints.openai.chat_completion.protocol import (
ChatCompletionNamedToolChoiceParam,
ChatCompletionRequest,
ChatCompletionToolsParam,
FunctionDefinition,
)
from vllm.entrypoints.openai.engine.protocol import (
DeltaMessage,
@@ -115,6 +116,23 @@ def sample_tools(request):
]
def _with_strict(
tools: list[ChatCompletionToolsParam],
) -> list[ChatCompletionToolsParam]:
return [
ChatCompletionToolsParam(
type=t.type,
function=FunctionDefinition(
name=t.function.name,
description=t.function.description,
parameters=t.function.parameters,
strict=True,
),
)
for t in tools
]
def _as_chat_completion_tools(
tools: list[ChatCompletionToolsParam | FunctionTool],
) -> list[ChatCompletionToolsParam]:
@@ -1323,10 +1341,11 @@ def test_get_vllm_registry_structural_tag_returns_structural_tag(
sample_tools: list[ChatCompletionToolsParam],
) -> None:
request_tools = _as_chat_completion_tools(sample_tools)
strict_tools = _with_strict(request_tools)
req = ChatCompletionRequest(
messages=[],
model="m",
tools=request_tools,
tools=strict_tools,
tool_choice="auto",
)
tag = qwen3_tool_parser.get_structural_tag(req)
@@ -1364,10 +1383,11 @@ def test_adjust_request_auto_uses_vllm_registry_structural_tag(
tool_parser_cls = Qwen3EngineToolParser
request_tools = _as_chat_completion_tools(sample_tools)
strict_tools = _with_strict(request_tools)
req = ChatCompletionRequest(
messages=[],
model="m",
tools=request_tools,
tools=strict_tools,
tool_choice="auto",
include_reasoning=include_reasoning,
)