diff --git a/tests/entrypoints/test_responses_utils.py b/tests/entrypoints/test_responses_utils.py index 893d806b6..3951bd484 100644 --- a/tests/entrypoints/test_responses_utils.py +++ b/tests/entrypoints/test_responses_utils.py @@ -5,6 +5,8 @@ import pytest from openai.types.responses.response_function_tool_call_output_item import ( ResponseFunctionToolCallOutputItem, ) +from openai.types.responses.response_output_message import ResponseOutputMessage +from openai.types.responses.response_output_text import ResponseOutputText from openai.types.responses.response_reasoning_item import ( Content, ResponseReasoningItem, @@ -101,3 +103,22 @@ class TestResponsesUtils: ) with pytest.raises(ValueError): construct_chat_message_with_tool_call(item) + + output_item = ResponseOutputMessage( + id="msg_bf585bbbe3d500e0", + content=[ + ResponseOutputText( + annotations=[], + text="dongyi", + type="output_text", + logprobs=None, + ) + ], + role="assistant", + status="completed", + type="message", + ) + + formatted_item = construct_chat_message_with_tool_call(output_item) + assert formatted_item["role"] == "assistant" + assert formatted_item["content"] == "dongyi" diff --git a/vllm/entrypoints/responses_utils.py b/vllm/entrypoints/responses_utils.py index 07abb80eb..2e01cb038 100644 --- a/vllm/entrypoints/responses_utils.py +++ b/vllm/entrypoints/responses_utils.py @@ -97,13 +97,18 @@ def construct_chat_message_with_tool_call( "role": "assistant", "reasoning": reasoning_content, } + elif isinstance(item, ResponseOutputMessage): + return { + "role": "assistant", + "content": item.content[0].text, + } elif isinstance(item, ResponseFunctionToolCallOutputItem): return ChatCompletionToolMessageParam( role="tool", content=item.output, tool_call_id=item.call_id, ) - elif item.get("type") == "function_call_output": + elif isinstance(item, dict) and item.get("type") == "function_call_output": # Append the function call output as a tool message. return ChatCompletionToolMessageParam( role="tool",