Skip to content

Commit 2ed3f20

Browse files
authored
[openai] Fix missing tool usage check (system message) (#24768)
Signed-off-by: kyt <[email protected]>
1 parent 48f3090 commit 2ed3f20

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

tests/entrypoints/openai/test_response_api_with_harmony.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,22 @@ async def test_function_calling_required(client: OpenAI, model_name: str):
698698
)
699699

700700

701+
@pytest.mark.asyncio
702+
@pytest.mark.parametrize("model_name", [MODEL_NAME])
703+
async def test_system_message_with_tools(client: OpenAI, model_name: str):
704+
from vllm.entrypoints.harmony_utils import get_system_message
705+
706+
# Test with custom tools enabled - commentary channel should be available
707+
sys_msg = get_system_message(with_custom_tools=True)
708+
valid_channels = sys_msg.content[0].channel_config.valid_channels
709+
assert "commentary" in valid_channels
710+
711+
# Test with custom tools disabled - commentary channel should be removed
712+
sys_msg = get_system_message(with_custom_tools=False)
713+
valid_channels = sys_msg.content[0].channel_config.valid_channels
714+
assert "commentary" not in valid_channels
715+
716+
701717
@pytest.mark.asyncio
702718
@pytest.mark.parametrize("model_name", [MODEL_NAME])
703719
async def test_function_calling_full_history(client: OpenAI, model_name: str):

vllm/entrypoints/openai/serving_chat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,9 @@ def _make_request_with_harmony(
15751575
sys_msg = get_system_message(
15761576
reasoning_effort=request.reasoning_effort,
15771577
browser_description=None,
1578-
python_description=None)
1578+
python_description=None,
1579+
with_custom_tools=request.tools is not None
1580+
)
15791581
messages.append(sys_msg)
15801582

15811583
# Add developer message.

0 commit comments

Comments
 (0)