From 61bc1bf9cc8659a88604d9363caa20a5933e0ec0 Mon Sep 17 00:00:00 2001 From: sa411022 Date: Fri, 22 Aug 2025 03:56:29 +0800 Subject: [PATCH] fix(openai): construct responses api input (#32557) --- libs/partners/openai/langchain_openai/chat_models/base.py | 8 +++++++- .../openai/tests/unit_tests/chat_models/test_base.py | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py index 1783bd052f5..082a167c97d 100644 --- a/libs/partners/openai/langchain_openai/chat_models/base.py +++ b/libs/partners/openai/langchain_openai/chat_models/base.py @@ -3749,7 +3749,13 @@ def _construct_responses_api_input(messages: Sequence[BaseMessage]) -> list: { "type": "message", "role": "assistant", - "content": [{"type": "output_text", "text": msg["content"]}], + "content": [ + { + "type": "output_text", + "text": msg["content"], + "annotations": [], + } + ], } ) diff --git a/libs/partners/openai/tests/unit_tests/chat_models/test_base.py b/libs/partners/openai/tests/unit_tests/chat_models/test_base.py index 1d79f2a2d91..761f2c6f101 100644 --- a/libs/partners/openai/tests/unit_tests/chat_models/test_base.py +++ b/libs/partners/openai/tests/unit_tests/chat_models/test_base.py @@ -2153,7 +2153,11 @@ def test__construct_responses_api_input_ai_message_with_tool_calls_and_content() assert result[0]["role"] == "assistant" assert result[0]["content"] == [ - {"type": "output_text", "text": "I'll check the weather for you."} + { + "type": "output_text", + "text": "I'll check the weather for you.", + "annotations": [], + } ] assert result[1]["type"] == "function_call" @@ -2255,6 +2259,7 @@ def test__construct_responses_api_input_multiple_message_types() -> None: { "type": "output_text", "text": "The weather in San Francisco is 72°F and sunny.", + "annotations": [], } ]