From b81c21f311fd131d5969c33d238be2eeed5cc522 Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Wed, 23 Apr 2025 17:48:47 -0700 Subject: [PATCH] docs updates --- docs/docs/concepts/human_in_the_loop.md | 33 --------------------- libs/langgraph/langgraph/pregel/__init__.py | 4 +-- libs/langgraph/langgraph/types.py | 2 +- 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/docs/docs/concepts/human_in_the_loop.md b/docs/docs/concepts/human_in_the_loop.md index 4d667b804..cc045b81b 100644 --- a/docs/docs/concepts/human_in_the_loop.md +++ b/docs/docs/concepts/human_in_the_loop.md @@ -409,39 +409,6 @@ The `Command` primitive provides several options to control and modify the graph By leveraging `Command`, you can resume graph execution, handle user inputs, and dynamically adjust the graph's state. -## Using with `invoke` and `ainvoke` - -When you use `stream` or `astream` to run the graph, you will receive an `Interrupt` event that let you know the `interrupt` was triggered. - -`invoke` and `ainvoke` do not return the interrupt information. To access this information, you must use the [get_state](../reference/graphs.md#langgraph.graph.graph.CompiledGraph.get_state) method to retrieve the graph state after calling `invoke` or `ainvoke`. - -```python -# Run the graph up to the interrupt -result = graph.invoke(inputs, thread_config) -# Get the graph state to get interrupt information. -state = graph.get_state(thread_config) -# Print the state values -print(state.values) -# Print the pending tasks -print(state.tasks) -# Resume the graph with the user's input. -graph.invoke(Command(resume={"age": "25"}), thread_config) -``` - -```pycon -{'foo': 'bar'} # State values -( - PregelTask( - id='5d8ffc92-8011-0c9b-8b59-9d3545b7e553', - name='node_foo', - path=('__pregel_pull', 'node_foo'), - error=None, - interrupts=(Interrupt(value='value_in_interrupt', resumable=True, ns=['node_foo:5d8ffc92-8011-0c9b-8b59-9d3545b7e553'], when='during'),), state=None, - result=None - ), -) # Pending tasks. interrupts -``` - ## How does resuming from an interrupt work? !!! warning diff --git a/libs/langgraph/langgraph/pregel/__init__.py b/libs/langgraph/langgraph/pregel/__init__.py index 9e7aa561d..14e98c460 100644 --- a/libs/langgraph/langgraph/pregel/__init__.py +++ b/libs/langgraph/langgraph/pregel/__init__.py @@ -2192,7 +2192,7 @@ class Pregel(PregelProtocol): stream_mode: The mode to stream output, defaults to self.stream_mode. Options are: - - `"values"`: Emit all values in the state after each step. + - `"values"`: Emit all values in the state after each step, including interrupts. When used with functional API, values are emitted once at the end of the workflow. - `"updates"`: Emit only the node or task names and updates returned by the nodes or tasks after each step. If multiple updates are made in the same step (e.g. multiple nodes are run) then those updates are emitted separately. @@ -2479,7 +2479,7 @@ class Pregel(PregelProtocol): stream_mode: The mode to stream output, defaults to self.stream_mode. Options are: - - `"values"`: Emit all values in the state after each step. + - `"values"`: Emit all values in the state after each step, including interrupts. When used with functional API, values are emitted once at the end of the workflow. - `"updates"`: Emit only the node or task names and updates returned by the nodes or tasks after each step. If multiple updates are made in the same step (e.g. multiple nodes are run) then those updates are emitted separately. diff --git a/libs/langgraph/langgraph/types.py b/libs/langgraph/langgraph/types.py index b2a681cb7..5462bafb2 100644 --- a/libs/langgraph/langgraph/types.py +++ b/libs/langgraph/langgraph/types.py @@ -49,7 +49,7 @@ Checkpointer = Union[None, bool, BaseCheckpointSaver] StreamMode = Literal["values", "updates", "debug", "messages", "custom"] """How the stream method should emit outputs. -- `"values"`: Emit all values in the state after each step. +- `"values"`: Emit all values in the state after each step, including interrupts. When used with functional API, values are emitted once at the end of the workflow. - `"updates"`: Emit only the node or task names and updates returned by the nodes or tasks after each step. If multiple updates are made in the same step (e.g. multiple nodes are run) then those updates are emitted separately.