@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / fa8804ad9c
Fork 0

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 12, 06:00 UTC

[responsesAPI][4] fix responseOutputItem Kimi K2 thinking bug (#29555)

Signed-off-by: Andrew Xia <axia@fb.com> Co-authored-by: Andrew Xia <axia@fb.com>

Andrew Xia committed Dec 1, 2025 at 18:11 UTC fa8804ad9c3f21dad3143418c7d9f40190f609ae
2 files changed +27 -1
tests/entrypoints/test_responses_utils.py
+21
@@ -5,6 +5,8 @@ import pytest
5 from openai.types.responses.response_function_tool_call_output_item import (
6 ResponseFunctionToolCallOutputItem,
7 )
8 +from openai.types.responses.response_output_message import ResponseOutputMessage
9 +from openai.types.responses.response_output_text import ResponseOutputText
10 from openai.types.responses.response_reasoning_item import (
11 Content,
12 ResponseReasoningItem,
@@ -101,3 +103,22 @@ class TestResponsesUtils:
103 )
104 with pytest.raises(ValueError):
105 construct_chat_message_with_tool_call(item)
106 +
107 + output_item = ResponseOutputMessage(
108 + id="msg_bf585bbbe3d500e0",
109 + content=[
110 + ResponseOutputText(
111 + annotations=[],
112 + text="dongyi",
113 + type="output_text",
114 + logprobs=None,
115 + )
116 + ],
117 + role="assistant",
118 + status="completed",
119 + type="message",
120 + )
121 +
122 + formatted_item = construct_chat_message_with_tool_call(output_item)
123 + assert formatted_item["role"] == "assistant"
124 + assert formatted_item["content"] == "dongyi"
vllm/entrypoints/responses_utils.py
+6 -1
@@ -97,13 +97,18 @@ def construct_chat_message_with_tool_call(
97 "role": "assistant",
98 "reasoning": reasoning_content,
99 }
100 + elif isinstance(item, ResponseOutputMessage):
101 + return {
102 + "role": "assistant",
103 + "content": item.content[0].text,
104 + }
105 elif isinstance(item, ResponseFunctionToolCallOutputItem):
106 return ChatCompletionToolMessageParam(
107 role="tool",
108 content=item.output,
109 tool_call_id=item.call_id,
110 )
106 - elif item.get("type") == "function_call_output":
111 + elif isinstance(item, dict) and item.get("type") == "function_call_output":
112 # Append the function call output as a tool message.
113 return ChatCompletionToolMessageParam(
114 role="tool",