From 847b9c13ac4edcb992c4518ea6808e8b1dc6380c Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Thu, 24 Apr 2025 12:36:35 -0700 Subject: [PATCH] adding docs example --- docs/docs/concepts/human_in_the_loop.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/docs/concepts/human_in_the_loop.md b/docs/docs/concepts/human_in_the_loop.md index cc045b81b..a4b63ca29 100644 --- a/docs/docs/concepts/human_in_the_loop.md +++ b/docs/docs/concepts/human_in_the_loop.md @@ -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