From 7aaa2bd5a83fd18121e3226c78c0b89b3a43367b Mon Sep 17 00:00:00 2001 From: Guillaume Calmettes Date: Wed, 23 Jul 2025 09:30:05 +0200 Subject: [PATCH] [Bugfix] ensure tool_choice is popped when `tool_choice:null` is passed in json payload (#19679) Signed-off-by: Guillaume Calmettes --- vllm/entrypoints/openai/protocol.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vllm/entrypoints/openai/protocol.py b/vllm/entrypoints/openai/protocol.py index 95e5bcd3b..6c6ec207a 100644 --- a/vllm/entrypoints/openai/protocol.py +++ b/vllm/entrypoints/openai/protocol.py @@ -841,7 +841,7 @@ class ChatCompletionRequest(OpenAIBaseModel): return data # if "tool_choice" is specified -- validation - if "tool_choice" in data: + if "tool_choice" in data and data["tool_choice"] is not None: # ensure that if "tool choice" is specified, tools are present if "tools" not in data or data["tools"] is None: @@ -853,7 +853,7 @@ class ChatCompletionRequest(OpenAIBaseModel): if data["tool_choice"] not in [ "auto", "required" ] and not isinstance(data["tool_choice"], dict): - raise NotImplementedError( + raise ValueError( f'Invalid value for `tool_choice`: {data["tool_choice"]}! '\ 'Only named tools, "none", "auto" or "required" '\ 'are supported.'