From 7ad1c19d9c89dff3a1b65867617ae54dc230b740 Mon Sep 17 00:00:00 2001 From: Sujal M H <63709163+sujalmh@users.noreply.github.com> Date: Thu, 8 Jan 2026 00:51:55 +0530 Subject: [PATCH] fix: handle empty assistant content in Responses API (#34272) (#34296) --- .../openai/langchain_openai/chat_models/base.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py index 2c9143f7cae..71109d9b4d8 100644 --- a/libs/partners/openai/langchain_openai/chat_models/base.py +++ b/libs/partners/openai/langchain_openai/chat_models/base.py @@ -4446,7 +4446,15 @@ def _convert_responses_chunk_to_generation_chunk( } ) elif chunk.type == "response.output_text.done": - content.append({"type": "text", "id": chunk.item_id, "index": current_index}) + _advance(chunk.output_index, chunk.content_index) + content.append( + { + "type": "text", + "text": "", + "id": chunk.item_id, + "index": current_index, + } + ) elif chunk.type == "response.created": id = chunk.response.id response_metadata["id"] = chunk.response.id # Backwards compatibility