Skip to content

The agent engineering platform.

fix(openai): Chat Message `Annotations` defaults to `[ ]` if not list or None (#32614)

Shahrukh Shaik4ba222148d82
diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py
index b01a560e23..1783bd052f 100644
--- a/libs/partners/openai/langchain_openai/chat_models/base.py
+++ b/libs/partners/openai/langchain_openai/chat_models/base.py
@@ -3875,7 +3875,9 @@ def _construct_lc_result_from_responses_api(
"annotations": [
annotation.model_dump()
for annotation in content.annotations
- ],
+ ]
+ if isinstance(content.annotations, list)
+ else [],
"id": output.id,
}
content_blocks.append(block)