[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
@@ -306,6 +306,20 @@ def _construct_message_from_response_item(
content=item.get("output"),
tool_call_id=item.get("call_id"),
)
elif isinstance(item, dict) and item.get("role") == "assistant":
content = item.get("content")
text: str | None = None
if isinstance(content, str):
text = content
elif isinstance(content, list) and content:
text = content[0].get("text")
if text is not None:
if prev_assistant_msg:
previous_content = prev_assistant_msg.get("content")
if previous_content is None:
prev_assistant_msg["content"] = text
return None
return {"role": "assistant", "content": text}
return item # type: ignore[arg-type]