Skip to content

The agent engineering platform.

fix: handle empty assistant content in Responses API (#34272) (#34296)

Sujal M H7ad1c19d9c89
diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py
index 2c9143f7ca..71109d9b4d 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