From b59daa1f7c18cc57394afa6f0d9cacdd339fdfbc Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Tue, 28 Apr 2026 17:49:29 -0400 Subject: [PATCH] fix(channels): correct _strip_extras dead branch for Required/NotRequired MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The second `if hasattr(t, "__origin__")` block was unreachable — the first branch always returned, so Required[T] / NotRequired[T] resolved to the bare class instead of the inner type. Check Required/NotRequired before the generic __origin__ fallback. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- libs/langgraph/langgraph/channels/binop.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/langgraph/langgraph/channels/binop.py b/libs/langgraph/langgraph/channels/binop.py index b33ea52fa..29fa2a22f 100644 --- a/libs/langgraph/langgraph/channels/binop.py +++ b/libs/langgraph/langgraph/channels/binop.py @@ -22,10 +22,9 @@ __all__ = ("BinaryOperatorAggregate",) def _strip_extras(t): # type: ignore[no-untyped-def] """Strips Annotated, Required and NotRequired from a given type.""" if hasattr(t, "__origin__"): + if t.__origin__ in (Required, NotRequired): + return _strip_extras(t.__args__[0]) return _strip_extras(t.__origin__) - if hasattr(t, "__origin__") and t.__origin__ in (Required, NotRequired): - return _strip_extras(t.__args__[0]) - return t