Skip to content

Commit 8516921

Browse files
committed
[Frontend] OpenAI Responses API supports Tool/Function calling
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com> [Frontend] OpenAI Responses API supports Tool/Function calling Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
1 parent ca01f3e commit 8516921

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

tests/v1/entrypoints/openai/responses/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from tests.utils import RemoteOpenAIServer
77

88
# Use a small reasoning model to test the responses API.
9-
MODEL_NAME = "Qwen/Qwen3-1.7B"
9+
MODEL_NAME = "Qwen/Qwen3-0.6B"
1010

1111

1212
@pytest.fixture(scope="module")

tests/v1/entrypoints/openai/responses/test_function_call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import openai # use the official client for correctness check
77
import pytest
88

9-
MODEL_NAME = "Qwen/Qwen3-1.7B"
9+
MODEL_NAME = "Qwen/Qwen3-0.6B"
1010
tools = [
1111
{
1212
"type": "function",

vllm/entrypoints/openai/serving_responses.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,9 @@ async def responses_full_generator(
350350
outputs.append(reasoning_item)
351351
if message_item:
352352
outputs.append(message_item)
353-
elif request.tool_choice is None or request.tool_choice == "none":
353+
elif (request.tool_choice == "none" and \
354+
not self.expand_tools_even_if_tool_choice_none) or \
355+
request.tool_choice is None:
354356
# No tool calls.
355357
if reasoning_item:
356358
outputs.append(reasoning_item)
@@ -372,7 +374,7 @@ async def responses_full_generator(
372374
ensure_ascii=False))
373375
for tool_call in tool_calls
374376
])
375-
elif request.tool_choice == "auto":
377+
elif request.tool_choice == "auto" or request.tool_choice == "none":
376378
try:
377379
tool_parser = self.tool_parser(tokenizer)
378380
except RuntimeError as e:
@@ -381,6 +383,7 @@ async def responses_full_generator(
381383
tool_call_info = tool_parser.extract_tool_calls(
382384
content if content is not None else "", request=request)
383385
if tool_call_info is not None and tool_call_info.tools_called:
386+
# extract_tool_calls() returns a list of tool calls.
384387
function_calls.extend(
385388
FunctionCall(
386389
name=tool_call.function.name,
@@ -476,6 +479,7 @@ def _construct_input_messages(
476479
else:
477480
for item in request.input:
478481
if item.get("type") == "function_call":
482+
# Append the function call as a tool call.
479483
messages.append({
480484
"role":
481485
"assistant",
@@ -489,6 +493,7 @@ def _construct_input_messages(
489493
}]
490494
})
491495
elif item.get("type") == "function_call_output":
496+
# Append the function call output as a tool message.
492497
messages.append({
493498
"role": "tool",
494499
"content": item.get("output", ""),

0 commit comments

Comments
 (0)