From 91f6fea068b44f5409459ea7bbfccd4d1d80a964 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Oct 2025 23:11:55 +0000 Subject: [PATCH] refactor(langgraph): simplify Send sanitization with dict comprehension Co-authored-by: sydney-runkle <54324534+sydney-runkle@users.noreply.github.com> --- libs/langgraph/langgraph/pregel/_algo.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libs/langgraph/langgraph/pregel/_algo.py b/libs/langgraph/langgraph/pregel/_algo.py index 08b5b3cc0..d8f061ff5 100644 --- a/libs/langgraph/langgraph/pregel/_algo.py +++ b/libs/langgraph/langgraph/pregel/_algo.py @@ -1121,14 +1121,10 @@ def sanitize_untracked_values_in_send( # Command return packet - sanitized_arg = dict(packet.arg) - - # top level keys should be the channel names - to_pop = set() - for k, v in sanitized_arg.items(): - if isinstance(channels.get(k), UntrackedValue): - to_pop.add(k) - for k in to_pop: - sanitized_arg.pop(k) + sanitized_arg = { + k: v + for k, v in packet.arg.items() + if not isinstance(channels.get(k), UntrackedValue) + } return Send(node=packet.node, arg=sanitized_arg)