From 37ea45d0657144d0fa63dae554f375b8804f6273 Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Fri, 27 Feb 2026 14:30:18 -0500 Subject: [PATCH] chore: simplify invoke interrupt collection The loop already merges __interrupt__ into the values dict in output_writes(), so invoke/ainvoke don't need to subscribe to both "updates" and "values" stream modes. Simplify to just use stream_mode="values" and read interrupts directly from the values payload. Co-Authored-By: Claude Opus 4.6 --- libs/langgraph/langgraph/pregel/main.py | 38 ++++--------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/libs/langgraph/langgraph/pregel/main.py b/libs/langgraph/langgraph/pregel/main.py index ae6a0014d..a5a3a7272 100644 --- a/libs/langgraph/langgraph/pregel/main.py +++ b/libs/langgraph/langgraph/pregel/main.py @@ -3095,9 +3095,7 @@ class Pregel( input, config, context=context, - stream_mode=["updates", "values"] - if stream_mode == "values" - else stream_mode, + stream_mode="values" if stream_mode == "values" else stream_mode, print_mode=print_mode, output_keys=output_keys, interrupt_before=interrupt_before, @@ -3106,20 +3104,9 @@ class Pregel( **kwargs, ): if stream_mode == "values": - if len(chunk) == 2: - mode, payload = cast(tuple[StreamMode, Any], chunk) - else: - _, mode, payload = cast( - tuple[tuple[str, ...], StreamMode, Any], chunk - ) - if ( - mode == "updates" - and isinstance(payload, dict) - and (ints := payload.get(INTERRUPT)) is not None - ): + latest = chunk + if isinstance(chunk, dict) and (ints := chunk.get(INTERRUPT)) is not None: interrupts.extend(ints) - elif mode == "values": - latest = payload else: chunks.append(chunk) @@ -3185,9 +3172,7 @@ class Pregel( input, config, context=context, - stream_mode=["updates", "values"] - if stream_mode == "values" - else stream_mode, + stream_mode="values" if stream_mode == "values" else stream_mode, print_mode=print_mode, output_keys=output_keys, interrupt_before=interrupt_before, @@ -3196,20 +3181,9 @@ class Pregel( **kwargs, ): if stream_mode == "values": - if len(chunk) == 2: - mode, payload = cast(tuple[StreamMode, Any], chunk) - else: - _, mode, payload = cast( - tuple[tuple[str, ...], StreamMode, Any], chunk - ) - if ( - mode == "updates" - and isinstance(payload, dict) - and (ints := payload.get(INTERRUPT)) is not None - ): + latest = chunk + if isinstance(chunk, dict) and (ints := chunk.get(INTERRUPT)) is not None: interrupts.extend(ints) - elif mode == "values": - latest = payload else: chunks.append(chunk)