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 5, 02:15 UTC
[bugfix] Normalize tool message content from array to string format (#39899)
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Jared Wen committed
Apr 17, 2026 at 02:54 UTC
afabb5f45a6ffa3d9cb2f7424db984a9b8290098
1 file changed
+12
vllm/entrypoints/chat_utils.py
+12
@@ -1550,6 +1550,18 @@ def _parse_chat_message_content(
1550
parsed_msg = _ToolParser(message)
1551
if "tool_call_id" in parsed_msg:
1552
result_msg["tool_call_id"] = parsed_msg["tool_call_id"]
1553
+ # Normalize tool message content from OpenAI array format to plain
1554
+ # string. Clients like Claude Code / Cursor send tool results as
1555
+ # [{"type": "text", "text": "..."}], but most chat templates only
1556
+ # handle string content for tool messages.
1557
+ msg_content = result_msg.get("content")
1558
+ if isinstance(msg_content, list):
1559
+ texts = [
1560
+ item.get("text", "")
1561
+ for item in msg_content
1562
+ if isinstance(item, dict) and item.get("type") == "text"
1563
+ ]
1564
+ result_msg["content"] = "\n".join(texts) if texts else ""
1565
1566
if "name" in message and isinstance(message["name"], str):
1567
result_msg["name"] = message["name"]