The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
fix(core): fix index checking when merging lists (#32431)
John Bledsoebc4251b9e007
diff --git a/libs/core/langchain_core/utils/_merge.py b/libs/core/langchain_core/utils/_merge.pyindex 4200ca304d..63d49de953 100644--- a/libs/core/langchain_core/utils/_merge.py+++ b/libs/core/langchain_core/utils/_merge.py@@ -97,7 +97,7 @@ def merge_lists(left: Optional[list], *others: Optional[list]) -> Optional[list]to_merge = [ifor i, e_left in enumerate(merged)- if e_left["index"] == e["index"]+ if "index" in e_left and e_left["index"] == e["index"]]if to_merge:# TODO: Remove this once merge_dict is updated with specialdiff --git a/libs/core/tests/unit_tests/test_messages.py b/libs/core/tests/unit_tests/test_messages.pyindex 58822433d7..0656a2f2e9 100644--- a/libs/core/tests/unit_tests/test_messages.py+++ b/libs/core/tests/unit_tests/test_messages.py@@ -1019,6 +1019,11 @@ def test_tool_message_str() -> None:("foo", [["bar"]], ["foo", "bar"]),(["foo"], ["bar"], ["foobar"]),(["foo"], [["bar"]], ["foo", "bar"]),+ (+ [{"text": "foo"}],+ [[{"index": 0, "text": "bar"}]],+ [{"text": "foo"}, {"index": 0, "text": "bar"}],+ ),],)def test_merge_content(