[Bugfix] Responses API assistant EasyInputMessageParam input (#44361)

Signed-off-by: Yifan Zong <yzong@redhat.com>
Co-authored-by: Ben Browning <bbrownin@redhat.com>
This commit is contained in:
yzong-rh
2026-06-23 08:54:46 -04:00
committed by GitHub
co-authored by Ben Browning
parent 7d47cff933
commit 2a675a7b9f
4 changed files with 93 additions and 13 deletions
@@ -5,7 +5,7 @@
import json
import pytest
from openai.types.responses import ResponseFunctionToolCall
from openai.types.responses import ResponseFunctionToolCall, ResponseOutputMessage
from vllm.entrypoints.openai.responses.protocol import ResponsesRequest
@@ -328,3 +328,52 @@ def test_validator_handles_empty_iterator():
request = ResponsesRequest(**mock_data)
assert request.input == []
def test_assistant_string_content_stays_easyinput():
"""EasyInput assistant message with plain string content is not
coerced into a ResponseOutputMessage."""
request_data = {
"model": "test-model",
"input": [
{"type": "message", "role": "assistant", "content": "hello"},
],
}
request = ResponsesRequest(**request_data)
item = request.input[0]
assert isinstance(item, dict), (
"String-content assistant message should remain a dict (EasyInput), "
f"got {type(item)}"
)
assert item.get("content") == "hello"
assert "id" not in item
assert "status" not in item
def test_assistant_output_style_content_coerced():
"""Assistant message whose content is output-message-shaped (list of
output_text items) should be coerced to ResponseOutputMessage."""
request_data = {
"model": "test-model",
"input": [
{
"type": "message",
"role": "assistant",
"content": [{"type": "output_text", "text": "world"}],
},
],
}
request = ResponsesRequest(**request_data)
item = request.input[0]
assert isinstance(item, ResponseOutputMessage), (
"Output-style assistant message should be coerced to "
f"ResponseOutputMessage, got {type(item)}"
)
assert item.content[0].text == "world"
assert item.content[0].annotations == []
assert item.status == "completed"
assert item.id.startswith("msg_")
@@ -782,6 +782,16 @@ class TestConstructChatMessagesCombinePolicy:
["call_123", "call_456"],
id="reasoning-output-tool-call",
),
pytest.param(
[
make_reasoning_item(content_text="Let me think"),
{"type": "message", "role": "assistant", "content": "Hello"},
],
"Hello",
"Let me think",
None,
id="reasoning-easyinput-assistant",
),
],
)
def test_assistant_side_items_merge_until_tool_output(