revert(langgraph): restore logic to surface interrupts for stream_mod… (#6141)

### Description

Revert change in #5201 that prevented the surfacing of interrupts when
`stream_mode="values"`. [Comment highlighting affected
lines](https://github.com/langchain-ai/langgraph/pull/5201#discussion_r2344884841)

Resolves #5409 

### Test

Add test to verify interrupts are properly surfaced when
`stream_mode="values"` (`test_interrupt_stream_mode_values`)
This commit is contained in:
Caspar Broekhuizen
2025-09-14 19:11:19 -07:00
committed by GitHub
parent 8b55dff7a5
commit 9467a0e2bb
2 changed files with 24 additions and 1 deletions
+5 -1
View File
@@ -904,7 +904,11 @@ class PregelLoop:
)
}
]
self._emit("updates", lambda: iter(interrupts))
stream_modes = self.stream.modes if self.stream else []
if "updates" in stream_modes:
self._emit("updates", lambda: iter(interrupts))
elif "values" in stream_modes:
self._emit("values", lambda: iter(interrupts))
elif writes[0][0] != ERROR:
self._emit(
"updates",
+19
View File
@@ -8430,3 +8430,22 @@ def test_null_resume_disallowed_with_multiple_interrupts(
"text_1": "resume for prompt: original text 1",
"text_2": "resume for prompt: original text 2",
}
def test_interrupt_stream_mode_values():
"""Test that interrupts are surfaced when steam_mode='values'"""
class State(TypedDict):
human_input: str
def human_input_node(state: State) -> Command:
human_input = interrupt("interrupt")
return Command(update={"human_input": human_input})
builder = StateGraph(State)
builder.add_node(human_input_node)
builder.add_edge(START, "human_input_node")
app = builder.compile()
result = [*app.stream(State(), stream_mode="values")]
assert "__interrupt__" in result[-1]