Skip to content

Commit fa8804a

Browse files
qandrewAndrew Xia
andauthored
[responsesAPI][4] fix responseOutputItem Kimi K2 thinking bug (#29555)
Signed-off-by: Andrew Xia <[email protected]> Co-authored-by: Andrew Xia <[email protected]>
1 parent 4b40924 commit fa8804a

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

tests/entrypoints/test_responses_utils.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from openai.types.responses.response_function_tool_call_output_item import (
66
ResponseFunctionToolCallOutputItem,
77
)
8+
from openai.types.responses.response_output_message import ResponseOutputMessage
9+
from openai.types.responses.response_output_text import ResponseOutputText
810
from openai.types.responses.response_reasoning_item import (
911
Content,
1012
ResponseReasoningItem,
@@ -101,3 +103,22 @@ def test_construct_chat_message_with_tool_call(self):
101103
)
102104
with pytest.raises(ValueError):
103105
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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,18 @@ def construct_chat_message_with_tool_call(
9797
"role": "assistant",
9898
"reasoning": reasoning_content,
9999
}
100+
elif isinstance(item, ResponseOutputMessage):
101+
return {
102+
"role": "assistant",
103+
"content": item.content[0].text,
104+
}
100105
elif isinstance(item, ResponseFunctionToolCallOutputItem):
101106
return ChatCompletionToolMessageParam(
102107
role="tool",
103108
content=item.output,
104109
tool_call_id=item.call_id,
105110
)
106-
elif item.get("type") == "function_call_output":
111+
elif isinstance(item, dict) and item.get("type") == "function_call_output":
107112
# Append the function call output as a tool message.
108113
return ChatCompletionToolMessageParam(
109114
role="tool",

0 commit comments

Comments
 (0)