adding docs example

This commit is contained in:
Sydney Runkle
2025-04-24 12:36:35 -07:00
parent b6963d35aa
commit 847b9c13ac
+19
View File
@@ -440,6 +440,25 @@ Upon **resuming** the graph, the counter will be incremented a second time, resu
The value of counter is: 2
```
### Resuming multiple interrupts with one invocation
The [`Command`][langgraph.types.Command] constructor supports a [`resume_map`][langgraph.types.Command.resume_map] argument
that you can use to specify a mapping of interrupt ids to their corresponding resume values.
This is helpful for the case of resuming multiple interrupts with a single invocation.
For example, once your graph has been interrupted (multiple times, theoretically) and is paused:
```python
resume_map: dict[str, Any] = {}
for task in parent_graph.get_state(thread_config).tasks:
for i in task.interrupts:
resume_map[i.interrupt_id] = f"human input for prompt {i.value}"
parent_graph.invoke(Command(resume_map=resume_map), config=thread_config)
```
Note, we plan to introduce an interrupts convenience attribute on `get_state()`'s result in the near future.
## Common Pitfalls
### Side-effects