A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 14, 22:35 UTC
[Frontend] Align tool_choice="required" behavior with OpenAI when tools is empty (#21052)
Signed-off-by: Sungyoon Jeong <sungyoon.jeong@furiosa.ai>
Sungyoon Jeong committed
Aug 1, 2025 at 16:54 UTC
98df153abfcc443218aacfe61b3fd5abe2b88142
1 file changed
+9
vllm/entrypoints/openai/protocol.py
+9
@@ -859,6 +859,15 @@ class ChatCompletionRequest(OpenAIBaseModel):
859
'are supported.'
860
)
861
862
+ # if tool_choice is "required" but the "tools" list is empty,
863
+ # override the data to behave like "none" to align with
864
+ # OpenAI’s behavior.
865
+ if data["tool_choice"] == "required" and isinstance(
866
+ data["tools"], list) and len(data["tools"]) == 0:
867
+ data["tool_choice"] = "none"
868
+ del data["tools"]
869
+ return data
870
+
871
# ensure that if "tool_choice" is specified as an object,
872
# it matches a valid tool
873
correct_usage_message = 'Correct usage: `{"type": "function",' \