[openai] Fix missing tool usage check (system message) (#24768)

Signed-off-by: kyt <eluban4532@gmail.com>
Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
kyt 2025-10-03 19:55:44 +09:00 committed by yewentao256
parent 2168fc8fae
commit fa29d31f0d
2 changed files with 19 additions and 1 deletions

View File

@ -698,6 +698,22 @@ async def test_function_calling_required(client: OpenAI, model_name: str):
)
@pytest.mark.asyncio
@pytest.mark.parametrize("model_name", [MODEL_NAME])
async def test_system_message_with_tools(client: OpenAI, model_name: str):
from vllm.entrypoints.harmony_utils import get_system_message
# Test with custom tools enabled - commentary channel should be available
sys_msg = get_system_message(with_custom_tools=True)
valid_channels = sys_msg.content[0].channel_config.valid_channels
assert "commentary" in valid_channels
# Test with custom tools disabled - commentary channel should be removed
sys_msg = get_system_message(with_custom_tools=False)
valid_channels = sys_msg.content[0].channel_config.valid_channels
assert "commentary" not in valid_channels
@pytest.mark.asyncio
@pytest.mark.parametrize("model_name", [MODEL_NAME])
async def test_function_calling_full_history(client: OpenAI, model_name: str):

View File

@ -1575,7 +1575,9 @@ class OpenAIServingChat(OpenAIServing):
sys_msg = get_system_message(
reasoning_effort=request.reasoning_effort,
browser_description=None,
python_description=None)
python_description=None,
with_custom_tools=request.tools is not None
)
messages.append(sys_msg)
# Add developer message.