diff --git a/docs/features/tool_calling.md b/docs/features/tool_calling.md index 8858b9a4015..445e370e3c2 100644 --- a/docs/features/tool_calling.md +++ b/docs/features/tool_calling.md @@ -103,9 +103,7 @@ When tool_choice='required' is set, the model is guaranteed to generate one or m 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. -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. - -Note: This behavior will change in v0.10.0, where tool definitions will be included by default even with `tool_choice='none'`. +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. ## Automatic Function Calling diff --git a/vllm/entrypoints/openai/api_server.py b/vllm/entrypoints/openai/api_server.py index 6c0a95ebb1e..8f4c24eb4ee 100644 --- a/vllm/entrypoints/openai/api_server.py +++ b/vllm/entrypoints/openai/api_server.py @@ -1282,8 +1282,8 @@ async def init_app_state( chat_template_content_format=args.chat_template_content_format, return_tokens_as_token_ids=args.return_tokens_as_token_ids, enable_auto_tools=args.enable_auto_tool_choice, - expand_tools_even_if_tool_choice_none=args. - expand_tools_even_if_tool_choice_none, + exclude_tools_when_tool_choice_none=args. + exclude_tools_when_tool_choice_none, tool_parser=args.tool_call_parser, reasoning_parser=args.reasoning_parser, enable_prompt_tokens_details=args.enable_prompt_tokens_details, diff --git a/vllm/entrypoints/openai/cli_args.py b/vllm/entrypoints/openai/cli_args.py index 4f8aaab772f..29a553726c4 100644 --- a/vllm/entrypoints/openai/cli_args.py +++ b/vllm/entrypoints/openai/cli_args.py @@ -224,16 +224,10 @@ def make_arg_parser(parser: FlexibleArgumentParser) -> FlexibleArgumentParser: help="Enable auto tool choice for supported models. Use " "``--tool-call-parser`` to specify which parser to use.") parser.add_argument( - "--expand-tools-even-if-tool-choice-none", + "--exclude-tools-when-tool-choice-none", action="store_true", default=False, - deprecated=True, - help="Include tool definitions in prompts " - "even when tool_choice='none'. " - "This is a transitional option that will be removed in v0.10.0. " - "In v0.10.0, tool definitions will always be included regardless of " - "tool_choice setting. Use this flag now to test the new behavior " - "before the breaking change.") + help="Exclude tool definitions in prompts when tool_choice='none'.") valid_tool_parsers = ToolParserManager.tool_parsers.keys() parser.add_argument( diff --git a/vllm/entrypoints/openai/serving_chat.py b/vllm/entrypoints/openai/serving_chat.py index a802fbc3865..4e132eedb86 100644 --- a/vllm/entrypoints/openai/serving_chat.py +++ b/vllm/entrypoints/openai/serving_chat.py @@ -63,7 +63,7 @@ def __init__( return_tokens_as_token_ids: bool = False, reasoning_parser: str = "", enable_auto_tools: bool = False, - expand_tools_even_if_tool_choice_none: bool = False, + exclude_tools_when_tool_choice_none: bool = False, tool_parser: Optional[str] = None, enable_prompt_tokens_details: bool = False, enable_force_include_usage: bool = False, @@ -112,8 +112,8 @@ def __init__( raise TypeError("Error: --enable-auto-tool-choice requires " f"tool_parser:'{tool_parser}' which has not " "been registered") from e - self.expand_tools_even_if_tool_choice_none = ( - expand_tools_even_if_tool_choice_none) + self.exclude_tools_when_tool_choice_none = ( + exclude_tools_when_tool_choice_none) self.enable_prompt_tokens_details = enable_prompt_tokens_details self.enable_force_include_usage = enable_force_include_usage @@ -179,21 +179,9 @@ async def create_chat_completion( "--enable-auto-tool-choice and --tool-call-parser to be set" ) - if request.tools is None: - tool_dicts = None - elif (request.tool_choice == "none" - and not self.expand_tools_even_if_tool_choice_none): - if len(request.tools) > 0: - logger.warning_once( - "Tools are specified but tool_choice is set to 'none' " - "and --expand-tools-even-if-tool-choice-none is not " - "enabled. Tool definitions will be excluded from the " - "prompt. This behavior will change in vLLM v0.10 where " - "tool definitions will be included by default even " - "with tool_choice='none'. To adopt the new behavior " - "now, use --expand-tools-even-if-tool-choice-none. " - "To suppress this warning, either remove tools from " - "the request or set tool_choice to a different value.") + if (request.tools is None + or (request.tool_choice == "none" + and self.exclude_tools_when_tool_choice_none)): tool_dicts = None else: tool_dicts = [tool.model_dump() for tool in request.tools]