Skip to content

Commit c06373d

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 99df4c3 commit c06373d

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
@@ -351,7 +351,9 @@ async def responses_full_generator(
351351
outputs.append(reasoning_item)
352352
if message_item:
353353
outputs.append(message_item)
354-
elif request.tool_choice is None or request.tool_choice == "none":
354+
elif (request.tool_choice == "none" and \
355+
not self.expand_tools_even_if_tool_choice_none) or \
356+
request.tool_choice is None:
355357
# No tool calls.
356358
if reasoning_item:
357359
outputs.append(reasoning_item)
@@ -373,7 +375,7 @@ async def responses_full_generator(
373375
ensure_ascii=False))
374376
for tool_call in tool_calls
375377
])
376-
elif request.tool_choice == "auto":
378+
elif request.tool_choice == "auto" or request.tool_choice == "none":
377379
try:
378380
tool_parser = self.tool_parser(tokenizer)
379381
except RuntimeError as e:
@@ -382,6 +384,7 @@ async def responses_full_generator(
382384
tool_call_info = tool_parser.extract_tool_calls(
383385
content if content is not None else "", request=request)
384386
if tool_call_info is not None and tool_call_info.tools_called:
387+
# extract_tool_calls() returns a list of tool calls.
385388
function_calls.extend(
386389
FunctionCall(
387390
name=tool_call.function.name,
@@ -477,6 +480,7 @@ def _construct_input_messages(
477480
else:
478481
for item in request.input:
479482
if item.get("type") == "function_call":
483+
# Append the function call as a tool call.
480484
messages.append({
481485
"role":
482486
"assistant",
@@ -490,6 +494,7 @@ def _construct_input_messages(
490494
}]
491495
})
492496
elif item.get("type") == "function_call_output":
497+
# Append the function call output as a tool message.
493498
messages.append({
494499
"role": "tool",
495500
"content": item.get("output", ""),

0 commit comments

Comments
 (0)