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 11, 11:15 UTC
[Bugfix] Drop empty tool_calls lists to keep assistant replies in chat template (#30648)
Signed-off-by: Seokhyun An <iamseokhyun@gmail.com>
Seokhyun An committed
Dec 15, 2025 at 13:21 UTC
b337647aa0ce103a84aac1e07a8fd738a5a4f13f
1 file changed
+11
-6
vllm/entrypoints/chat_utils.py
+11
-6
@@ -1629,12 +1629,17 @@ def _postprocess_messages(messages: list[ConversationMessage]) -> None:
1629
# so, for messages that have tool_calls, parse the string (which we get
1630
# from openAI format) to dict
1631
for message in messages:
1632
- if (
1633
- message["role"] == "assistant"
1634
- and "tool_calls" in message
1635
- and isinstance(message["tool_calls"], list)
1636
- ):
1637
- for item in message["tool_calls"]:
1632
+ if message["role"] == "assistant" and "tool_calls" in message:
1633
+ tool_calls = message.get("tool_calls")
1634
+ if not isinstance(tool_calls, list):
1635
+ continue
1636
+
1637
+ if len(tool_calls) == 0:
1638
+ # Drop empty tool_calls to keep templates on the normal assistant path.
1639
+ message.pop("tool_calls", None)
1640
+ continue
1641
+
1642
+ for item in tool_calls:
1643
# if arguments is None or empty string, set to {}
1644
if content := item["function"].get("arguments"):
1645
if not isinstance(content, (dict, list)):