From 4dc1195bcdd8642472978ef4d896781dd3e5b7f6 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Fri, 19 Jul 2024 14:46:01 -0700 Subject: [PATCH] Don't include lambdas in __eq__ for BinOp When using forward refs, inline lambdas in Annotated are re-evaluated for every subclass, thus making the comparison fail --- libs/langgraph/langgraph/channels/binop.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/langgraph/langgraph/channels/binop.py b/libs/langgraph/langgraph/channels/binop.py index e7969a100..72e76c0a7 100644 --- a/libs/langgraph/langgraph/channels/binop.py +++ b/libs/langgraph/langgraph/channels/binop.py @@ -56,9 +56,11 @@ class BinaryOperatorAggregate(Generic[Value], BaseChannel[Value, Value, Value]): pass def __eq__(self, value: object) -> bool: - return ( - isinstance(value, BinaryOperatorAggregate) - and value.operator == self.operator + return isinstance(value, BinaryOperatorAggregate) and ( + value.operator is self.operator + if value.operator.__name__ != "" + and self.operator.__name__ != "" + else True ) @property