Skip to content

Commit 4fe2231

Browse files
committed
remove --expand-tools-even-if-tool-choice-none and add --exclude-tools-when-tool-choice-none
Signed-off-by: okada <kokuzen@gmail.com>
1 parent 8aeaa91 commit 4fe2231

File tree

4 files changed

+9
-28
lines changed

4 files changed

+9
-28
lines changed

docs/features/tool_calling.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ When tool_choice='required' is set, the model is guaranteed to generate one or m
103103

104104
vLLM supports the `tool_choice='none'` option in the chat completion API. When this option is set, the model will not generate any tool calls and will respond with regular text content only, even if tools are defined in the request.
105105

106-
By default, when `tool_choice='none'` is specified, vLLM excludes tool definitions from the prompt to optimize context usage. To include tool definitions even with `tool_choice='none'`, use the `--expand-tools-even-if-tool-choice-none` option.
107-
108-
Note: This behavior will change in v0.10.0, where tool definitions will be included by default even with `tool_choice='none'`.
106+
Note: When tools are specified in the request, vLLM includes tool definitions in the prompt by default, regardless of the `tool_choice` setting. To exclude tool definitions when `tool_choice='none'`, use the `--exclude-tools-when-tool-choice-none` option.
109107

110108
## Automatic Function Calling
111109

vllm/entrypoints/openai/api_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,8 +1282,8 @@ async def init_app_state(
12821282
chat_template_content_format=args.chat_template_content_format,
12831283
return_tokens_as_token_ids=args.return_tokens_as_token_ids,
12841284
enable_auto_tools=args.enable_auto_tool_choice,
1285-
expand_tools_even_if_tool_choice_none=args.
1286-
expand_tools_even_if_tool_choice_none,
1285+
exclude_tools_when_tool_choice_none=args.
1286+
exclude_tools_when_tool_choice_none,
12871287
tool_parser=args.tool_call_parser,
12881288
reasoning_parser=args.reasoning_parser,
12891289
enable_prompt_tokens_details=args.enable_prompt_tokens_details,

vllm/entrypoints/openai/cli_args.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,10 @@ def make_arg_parser(parser: FlexibleArgumentParser) -> FlexibleArgumentParser:
224224
help="Enable auto tool choice for supported models. Use "
225225
"``--tool-call-parser`` to specify which parser to use.")
226226
parser.add_argument(
227-
"--expand-tools-even-if-tool-choice-none",
227+
"--exclude-tools-when-tool-choice-none",
228228
action="store_true",
229229
default=False,
230-
deprecated=True,
231-
help="Include tool definitions in prompts "
232-
"even when tool_choice='none'. "
233-
"This is a transitional option that will be removed in v0.10.0. "
234-
"In v0.10.0, tool definitions will always be included regardless of "
235-
"tool_choice setting. Use this flag now to test the new behavior "
236-
"before the breaking change.")
230+
help="Exclude tool definitions in prompts when tool_choice='none'.")
237231

238232
valid_tool_parsers = ToolParserManager.tool_parsers.keys()
239233
parser.add_argument(

vllm/entrypoints/openai/serving_chat.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(
6363
return_tokens_as_token_ids: bool = False,
6464
reasoning_parser: str = "",
6565
enable_auto_tools: bool = False,
66-
expand_tools_even_if_tool_choice_none: bool = False,
66+
exclude_tools_when_tool_choice_none: bool = False,
6767
tool_parser: Optional[str] = None,
6868
enable_prompt_tokens_details: bool = False,
6969
enable_force_include_usage: bool = False,
@@ -112,8 +112,8 @@ def __init__(
112112
raise TypeError("Error: --enable-auto-tool-choice requires "
113113
f"tool_parser:'{tool_parser}' which has not "
114114
"been registered") from e
115-
self.expand_tools_even_if_tool_choice_none = (
116-
expand_tools_even_if_tool_choice_none)
115+
self.exclude_tools_when_tool_choice_none = (
116+
exclude_tools_when_tool_choice_none)
117117

118118
self.enable_prompt_tokens_details = enable_prompt_tokens_details
119119
self.enable_force_include_usage = enable_force_include_usage
@@ -182,18 +182,7 @@ async def create_chat_completion(
182182
if request.tools is None:
183183
tool_dicts = None
184184
elif (request.tool_choice == "none"
185-
and not self.expand_tools_even_if_tool_choice_none):
186-
if len(request.tools) > 0:
187-
logger.warning_once(
188-
"Tools are specified but tool_choice is set to 'none' "
189-
"and --expand-tools-even-if-tool-choice-none is not "
190-
"enabled. Tool definitions will be excluded from the "
191-
"prompt. This behavior will change in vLLM v0.10 where "
192-
"tool definitions will be included by default even "
193-
"with tool_choice='none'. To adopt the new behavior "
194-
"now, use --expand-tools-even-if-tool-choice-none. "
195-
"To suppress this warning, either remove tools from "
196-
"the request or set tool_choice to a different value.")
185+
and self.exclude_tools_when_tool_choice_none):
197186
tool_dicts = None
198187
else:
199188
tool_dicts = [tool.model_dump() for tool in request.tools]

0 commit comments

Comments
 (0)