langgraph 1.2.19__tar.gz → 1.2.20__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. {langgraph-1.2.19 → langgraph-1.2.20}/PKG-INFO +1 -1
  2. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_constants.py +3 -0
  3. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/errors.py +40 -0
  4. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_algo.py +15 -9
  5. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_loop.py +33 -3
  6. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_retry.py +21 -0
  7. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/remote.py +2 -0
  8. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/types.py +15 -3
  9. {langgraph-1.2.19 → langgraph-1.2.20}/pyproject.toml +1 -1
  10. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_remote_graph.py +2 -1
  11. langgraph-1.2.20/tests/test_strict_resume.py +423 -0
  12. {langgraph-1.2.19 → langgraph-1.2.20}/uv.lock +34 -35
  13. {langgraph-1.2.19 → langgraph-1.2.20}/.gitignore +0 -0
  14. {langgraph-1.2.19 → langgraph-1.2.20}/LICENSE +0 -0
  15. {langgraph-1.2.19 → langgraph-1.2.20}/Makefile +0 -0
  16. {langgraph-1.2.19 → langgraph-1.2.20}/README.md +0 -0
  17. {langgraph-1.2.19 → langgraph-1.2.20}/bench/__init__.py +0 -0
  18. {langgraph-1.2.19 → langgraph-1.2.20}/bench/__main__.py +0 -0
  19. {langgraph-1.2.19 → langgraph-1.2.20}/bench/fanout_to_subgraph.py +0 -0
  20. {langgraph-1.2.19 → langgraph-1.2.20}/bench/pydantic_state.py +0 -0
  21. {langgraph-1.2.19 → langgraph-1.2.20}/bench/react_agent.py +0 -0
  22. {langgraph-1.2.19 → langgraph-1.2.20}/bench/sequential.py +0 -0
  23. {langgraph-1.2.19 → langgraph-1.2.20}/bench/serde_allowlist.py +0 -0
  24. {langgraph-1.2.19 → langgraph-1.2.20}/bench/wide_dict.py +0 -0
  25. {langgraph-1.2.19 → langgraph-1.2.20}/bench/wide_state.py +0 -0
  26. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/__init__.py +0 -0
  27. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_cache.py +0 -0
  28. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_config.py +0 -0
  29. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_fields.py +0 -0
  30. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_future.py +0 -0
  31. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_pydantic.py +0 -0
  32. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_queue.py +0 -0
  33. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_replay.py +0 -0
  34. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_retry.py +0 -0
  35. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_runnable.py +0 -0
  36. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_scratchpad.py +0 -0
  37. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_serde.py +0 -0
  38. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_timeout.py +0 -0
  39. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/_internal/_typing.py +0 -0
  40. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/callbacks.py +0 -0
  41. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/channels/__init__.py +0 -0
  42. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/channels/any_value.py +0 -0
  43. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/channels/base.py +0 -0
  44. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/channels/binop.py +0 -0
  45. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/channels/delta.py +0 -0
  46. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/channels/ephemeral_value.py +0 -0
  47. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/channels/last_value.py +0 -0
  48. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/channels/named_barrier_value.py +0 -0
  49. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/channels/topic.py +0 -0
  50. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/channels/untracked_value.py +0 -0
  51. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/config.py +0 -0
  52. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/constants.py +0 -0
  53. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/func/__init__.py +0 -0
  54. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/graph/__init__.py +0 -0
  55. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/graph/_branch.py +0 -0
  56. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/graph/_node.py +0 -0
  57. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/graph/message.py +0 -0
  58. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/graph/state.py +0 -0
  59. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/graph/ui.py +0 -0
  60. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/managed/__init__.py +0 -0
  61. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/managed/base.py +0 -0
  62. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/managed/is_last_step.py +0 -0
  63. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/__init__.py +0 -0
  64. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_call.py +0 -0
  65. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_checkpoint.py +0 -0
  66. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_config.py +0 -0
  67. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_draw.py +0 -0
  68. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_executor.py +0 -0
  69. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_io.py +0 -0
  70. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_log.py +0 -0
  71. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_messages.py +0 -0
  72. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_read.py +0 -0
  73. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_remote_run_stream.py +0 -0
  74. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_runner.py +0 -0
  75. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_task_status.py +0 -0
  76. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_tools.py +0 -0
  77. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_utils.py +0 -0
  78. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_validate.py +0 -0
  79. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/_write.py +0 -0
  80. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/debug.py +0 -0
  81. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/main.py +0 -0
  82. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/protocol.py +0 -0
  83. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/pregel/types.py +0 -0
  84. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/py.typed +0 -0
  85. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/runtime.py +0 -0
  86. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/stream/__init__.py +0 -0
  87. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/stream/_convert.py +0 -0
  88. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/stream/_mux.py +0 -0
  89. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/stream/_types.py +0 -0
  90. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/stream/run_stream.py +0 -0
  91. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/stream/stream_channel.py +0 -0
  92. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/stream/transformers.py +0 -0
  93. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/typing.py +0 -0
  94. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/utils/__init__.py +0 -0
  95. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/utils/config.py +0 -0
  96. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/utils/runnable.py +0 -0
  97. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/version.py +0 -0
  98. {langgraph-1.2.19 → langgraph-1.2.20}/langgraph/warnings.py +0 -0
  99. {langgraph-1.2.19 → langgraph-1.2.20}/tests/__init__.py +0 -0
  100. {langgraph-1.2.19 → langgraph-1.2.20}/tests/__snapshots__/test_large_cases.ambr +0 -0
  101. {langgraph-1.2.19 → langgraph-1.2.20}/tests/__snapshots__/test_pregel.ambr +0 -0
  102. {langgraph-1.2.19 → langgraph-1.2.20}/tests/__snapshots__/test_pregel_async.ambr +0 -0
  103. {langgraph-1.2.19 → langgraph-1.2.20}/tests/agents.py +0 -0
  104. {langgraph-1.2.19 → langgraph-1.2.20}/tests/any_int.py +0 -0
  105. {langgraph-1.2.19 → langgraph-1.2.20}/tests/any_str.py +0 -0
  106. {langgraph-1.2.19 → langgraph-1.2.20}/tests/compose-postgres.yml +0 -0
  107. {langgraph-1.2.19 → langgraph-1.2.20}/tests/compose-redis.yml +0 -0
  108. {langgraph-1.2.19 → langgraph-1.2.20}/tests/conftest.py +0 -0
  109. {langgraph-1.2.19 → langgraph-1.2.20}/tests/conftest_checkpointer.py +0 -0
  110. {langgraph-1.2.19 → langgraph-1.2.20}/tests/conftest_store.py +0 -0
  111. {langgraph-1.2.19 → langgraph-1.2.20}/tests/example_app/example_graph.py +0 -0
  112. {langgraph-1.2.19 → langgraph-1.2.20}/tests/example_app/langgraph.json +0 -0
  113. {langgraph-1.2.19 → langgraph-1.2.20}/tests/example_app/requirements.txt +0 -0
  114. {langgraph-1.2.19 → langgraph-1.2.20}/tests/fake_chat.py +0 -0
  115. {langgraph-1.2.19 → langgraph-1.2.20}/tests/fake_tracer.py +0 -0
  116. {langgraph-1.2.19 → langgraph-1.2.20}/tests/memory_assert.py +0 -0
  117. {langgraph-1.2.19 → langgraph-1.2.20}/tests/messages.py +0 -0
  118. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_algo.py +0 -0
  119. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_channels.py +0 -0
  120. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_checkpoint_migration.py +0 -0
  121. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_config_async.py +0 -0
  122. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_benchmark.py +0 -0
  123. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_exit_mode.py +0 -0
  124. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_fork.py +0 -0
  125. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_id_stability.py +0 -0
  126. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_migration.py +0 -0
  127. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_node_cache.py +0 -0
  128. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_parallel_order.py +0 -0
  129. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_run_input.py +0 -0
  130. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_seal_subscribers.py +0 -0
  131. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_subgraph.py +0 -0
  132. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_supersteps_bound.py +0 -0
  133. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_to_plain.py +0 -0
  134. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_update_overwrite.py +0 -0
  135. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_update_state.py +0 -0
  136. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_delta_channel_write_failures.py +0 -0
  137. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_deprecation.py +0 -0
  138. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_graph_callbacks.py +0 -0
  139. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_interleave_arrival_order.py +0 -0
  140. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_interrupt_migration.py +0 -0
  141. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_interrupt_state.py +0 -0
  142. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_interruption.py +0 -0
  143. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_large_cases.py +0 -0
  144. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_large_cases_async.py +0 -0
  145. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_managed_values.py +0 -0
  146. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_messages_state.py +0 -0
  147. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_parent_command.py +0 -0
  148. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_parent_command_async.py +0 -0
  149. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_pregel.py +0 -0
  150. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_pregel_async.py +0 -0
  151. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_pregel_debug.py +0 -0
  152. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_pregel_stream_events_v3.py +0 -0
  153. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_prune_postgres.py +0 -0
  154. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_pydantic.py +0 -0
  155. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_remote_graph_v3.py +0 -0
  156. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_retry.py +0 -0
  157. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_runnable.py +0 -0
  158. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_runtime.py +0 -0
  159. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_serde_allowlist.py +0 -0
  160. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_state.py +0 -0
  161. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_stream_before_builtins.py +0 -0
  162. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_stream_data_transformers.py +0 -0
  163. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_stream_events_v3.py +0 -0
  164. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_stream_events_v3_e2e.py +0 -0
  165. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_stream_events_v3_kwarg_forwarding.py +0 -0
  166. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_stream_lifecycle_transformer.py +0 -0
  167. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_stream_messages_transformer.py +0 -0
  168. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_stream_namespaces.py +0 -0
  169. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_stream_subgraph_transformer.py +0 -0
  170. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_subgraph_detection.py +0 -0
  171. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_subgraph_persistence.py +0 -0
  172. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_subgraph_persistence_async.py +0 -0
  173. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_time_travel.py +0 -0
  174. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_time_travel_async.py +0 -0
  175. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_tool_stream_handler.py +0 -0
  176. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_trace_policy.py +0 -0
  177. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_tracing_interops.py +0 -0
  178. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_type_checking.py +0 -0
  179. {langgraph-1.2.19 → langgraph-1.2.20}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: langgraph
3
- Version: 1.2.19
3
+ Version: 1.2.20
4
4
  Summary: Building stateful, multi-actor applications with LLMs
5
5
  Project-URL: Homepage, https://docs.langchain.com/oss/python/langgraph/overview
6
6
  Project-URL: Documentation, https://reference.langchain.com/python/langgraph/
@@ -74,6 +74,8 @@ CONFIG_KEY_RUNTIME = sys.intern("__pregel_runtime")
74
74
  # holds a `Runtime` instance with context, store, stream writer, etc.
75
75
  CONFIG_KEY_RESUME_MAP = sys.intern("__pregel_resume_map")
76
76
  # holds a mapping of task ns -> resume value for resuming tasks
77
+ CONFIG_KEY_STRICT_RESUME = sys.intern("__pregel_strict_resume")
78
+ # when True, the root graph refuses a resume that can't be matched to its pending interrupts
77
79
  CONFIG_KEY_STREAM_MESSAGES_V2 = sys.intern("__pregel_stream_messages_v2")
78
80
  # when True, attach StreamMessagesHandlerV2 so content-block (v2) events
79
81
  # flow through stream_mode="messages"; set by StreamingHandler only.
@@ -134,6 +136,7 @@ RESERVED = {
134
136
  CONFIG_KEY_CHECKPOINT_NS,
135
137
  CONFIG_KEY_TIMED_ATTEMPT_OBSERVER,
136
138
  CONFIG_KEY_RESUME_MAP,
139
+ CONFIG_KEY_STRICT_RESUME,
137
140
  CONFIG_KEY_STREAM_MESSAGES_V2,
138
141
  # other constants
139
142
  PUSH,
@@ -28,6 +28,7 @@ __all__ = (
28
28
  "ParentCommand",
29
29
  "EmptyInputError",
30
30
  "TaskNotFound",
31
+ "UnknownInterruptError",
31
32
  "is_invalid_resume",
32
33
  )
33
34
 
@@ -146,6 +147,45 @@ class TaskNotFound(Exception):
146
147
  pass
147
148
 
148
149
 
150
+ class UnknownInterruptError(Exception):
151
+ """Raised in strict resume mode when a resume doesn't match the pending interrupts.
152
+
153
+ `reason` says how it doesn't match:
154
+
155
+ - `"not_pending"`: the resume names interrupts that aren't pending, listed in
156
+ `interrupt_ids`.
157
+ - `"empty_map"`: the resume is an empty map.
158
+ - `"ambiguous"`: the resume is a single value while several interrupts are
159
+ pending.
160
+
161
+ `pending_ids` lists the interrupts still waiting for an answer. The error is
162
+ raised before anything is written, so they can still be answered.
163
+
164
+ A single value with no interrupt pending is accepted, because it resumes a
165
+ graph paused at a static breakpoint (`interrupt_before` or `interrupt_after`).
166
+
167
+ The interrupts one task raises share an id, so an answer retried after the
168
+ task asked its next question answers that question.
169
+ """
170
+
171
+ reason: Literal["not_pending", "empty_map", "ambiguous"]
172
+ interrupt_ids: tuple[str, ...]
173
+ pending_ids: tuple[str, ...]
174
+
175
+ def __init__(
176
+ self,
177
+ message: str,
178
+ *,
179
+ reason: Literal["not_pending", "empty_map", "ambiguous"],
180
+ interrupt_ids: Sequence[str] = (),
181
+ pending_ids: Sequence[str] = (),
182
+ ) -> None:
183
+ super().__init__(message)
184
+ self.reason = reason
185
+ self.interrupt_ids = tuple(interrupt_ids)
186
+ self.pending_ids = tuple(pending_ids)
187
+
188
+
149
189
  @dataclass(frozen=True, slots=True)
150
190
  class NodeError:
151
191
  """Failure context passed to a node-level error handler.
@@ -85,6 +85,7 @@ from langgraph.types import (
85
85
  RetryPolicy,
86
86
  Send,
87
87
  TimeoutPolicy,
88
+ _interrupt_id,
88
89
  )
89
90
 
90
91
  GetNextVersion = Callable[[V | None, None], V]
@@ -626,7 +627,7 @@ def prepare_single_task(
626
627
  config[CONF].get(CONFIG_KEY_SCRATCHPAD),
627
628
  pending_writes,
628
629
  task_id,
629
- xxh3_128_hexdigest(task_checkpoint_ns.encode()),
630
+ task_checkpoint_ns,
630
631
  config[CONF].get(CONFIG_KEY_RESUME_MAP),
631
632
  step,
632
633
  stop,
@@ -873,7 +874,7 @@ def prepare_push_task_functional(
873
874
  configurable.get(CONFIG_KEY_SCRATCHPAD),
874
875
  pending_writes,
875
876
  task_id,
876
- xxh3_128_hexdigest(task_checkpoint_ns.encode()),
877
+ task_checkpoint_ns,
877
878
  configurable.get(CONFIG_KEY_RESUME_MAP),
878
879
  step,
879
880
  stop,
@@ -1035,7 +1036,7 @@ def prepare_push_task_send(
1035
1036
  config[CONF].get(CONFIG_KEY_SCRATCHPAD),
1036
1037
  pending_writes,
1037
1038
  task_id,
1038
- xxh3_128_hexdigest(task_checkpoint_ns.encode()),
1039
+ task_checkpoint_ns,
1039
1040
  config[CONF].get(CONFIG_KEY_RESUME_MAP),
1040
1041
  step,
1041
1042
  stop,
@@ -1184,7 +1185,7 @@ def prepare_node_error_handler_task(
1184
1185
  config[CONF].get(CONFIG_KEY_SCRATCHPAD),
1185
1186
  pending_writes,
1186
1187
  task_id,
1187
- xxh3_128_hexdigest(task_checkpoint_ns.encode()),
1188
+ task_checkpoint_ns,
1188
1189
  config[CONF].get(CONFIG_KEY_RESUME_MAP),
1189
1190
  step,
1190
1191
  stop,
@@ -1280,7 +1281,7 @@ def _scratchpad(
1280
1281
  parent_scratchpad: PregelScratchpad | None,
1281
1282
  pending_writes: list[PendingWrite],
1282
1283
  task_id: str,
1283
- namespace_hash: str,
1284
+ task_checkpoint_ns: str,
1284
1285
  resume_map: dict[str, Any] | None,
1285
1286
  step: int,
1286
1287
  stop: int,
@@ -1307,10 +1308,15 @@ def _scratchpad(
1307
1308
  task_resume_write = []
1308
1309
  del w
1309
1310
 
1310
- # find namespace and task-specific resume value
1311
- if resume_map and namespace_hash in resume_map:
1312
- mapped_resume_write = resume_map[namespace_hash]
1313
- task_resume_write.append(mapped_resume_write)
1311
+ # find the resume value for the task's next interrupt
1312
+ if resume_map:
1313
+ next_id = _interrupt_id(task_checkpoint_ns, len(task_resume_write))
1314
+ first_id = _interrupt_id(task_checkpoint_ns, 0)
1315
+ if next_id in resume_map:
1316
+ task_resume_write.append(resume_map[next_id])
1317
+ # Older versions gave all of a task's interrupts the first id.
1318
+ elif first_id in resume_map:
1319
+ task_resume_write.append(resume_map[first_id])
1314
1320
 
1315
1321
  else:
1316
1322
  null_resume_write = None
@@ -48,6 +48,7 @@ from langgraph._internal._constants import (
48
48
  CONFIG_KEY_RUNTIME,
49
49
  CONFIG_KEY_SCRATCHPAD,
50
50
  CONFIG_KEY_STREAM,
51
+ CONFIG_KEY_STRICT_RESUME,
51
52
  CONFIG_KEY_TASK_ID,
52
53
  CONFIG_KEY_THREAD_ID,
53
54
  ERROR,
@@ -77,6 +78,7 @@ from langgraph.constants import TAG_HIDDEN
77
78
  from langgraph.errors import (
78
79
  EmptyInputError,
79
80
  GraphInterrupt,
81
+ UnknownInterruptError,
80
82
  )
81
83
  from langgraph.managed.base import (
82
84
  ManagedValueMapping,
@@ -1024,17 +1026,45 @@ class PregelLoop:
1024
1026
  "Cannot use Command(resume=...) without checkpointer"
1025
1027
  )
1026
1028
 
1029
+ strict = (
1030
+ self.config[CONF].get(CONFIG_KEY_STRICT_RESUME, False)
1031
+ # Nested calls inherit the parent's configurable.
1032
+ and not self.is_nested
1033
+ # A finished task can rerun and interrupt again on replay, while
1034
+ # its earlier output still makes its interrupt look answered.
1035
+ and not self._addressed_checkpoint_superseded
1036
+ )
1027
1037
  if resume_is_map := (
1028
1038
  isinstance(resume, dict)
1029
1039
  and all(is_xxh3_128_hexdigest(k) for k in resume)
1030
1040
  ):
1041
+ if strict:
1042
+ pending = self._pending_interrupts()
1043
+ if not resume:
1044
+ raise UnknownInterruptError(
1045
+ "The resume map names no interrupt",
1046
+ reason="empty_map",
1047
+ pending_ids=sorted(pending),
1048
+ )
1049
+ if unknown := sorted(resume.keys() - pending):
1050
+ raise UnknownInterruptError(
1051
+ f"Unknown or already-consumed interrupt: {unknown[0]}",
1052
+ reason="not_pending",
1053
+ interrupt_ids=unknown,
1054
+ pending_ids=sorted(pending),
1055
+ )
1031
1056
  self.config[CONF][CONFIG_KEY_RESUME_MAP] = resume
1032
1057
  else:
1033
- if len(self._pending_interrupts()) > 1:
1034
- raise RuntimeError(
1058
+ if len(pending := self._pending_interrupts()) > 1:
1059
+ message = (
1035
1060
  "When there are multiple pending interrupts, you must specify the interrupt id when resuming. "
1036
- "Docs: https://docs.langchain.com/oss/python/langgraph/add-human-in-the-loop#resume-multiple-interrupts-with-one-invocation."
1061
+ "Docs: https://docs.langchain.com/oss/python/langgraph/interrupts#handling-multiple-interrupts."
1037
1062
  )
1063
+ if strict:
1064
+ raise UnknownInterruptError(
1065
+ message, reason="ambiguous", pending_ids=sorted(pending)
1066
+ )
1067
+ raise RuntimeError(message)
1038
1068
 
1039
1069
  writes: defaultdict[str, list[tuple[str, Any]]] = defaultdict(list)
1040
1070
  # group writes by task ID
@@ -28,6 +28,7 @@ from langgraph._internal._constants import (
28
28
  CONFIG_KEY_CHECKPOINT_NS,
29
29
  CONFIG_KEY_RESUMING,
30
30
  CONFIG_KEY_RUNTIME,
31
+ CONFIG_KEY_SCRATCHPAD,
31
32
  CONFIG_KEY_SEND,
32
33
  CONFIG_KEY_STREAM,
33
34
  CONFIG_KEY_TASK_ID,
@@ -44,6 +45,7 @@ from langgraph.errors import (
44
45
  NodeTimeoutError,
45
46
  ParentCommand,
46
47
  )
48
+ from langgraph.pregel._algo import LazyAtomicCounter
47
49
  from langgraph.pregel.protocol import StreamProtocol
48
50
  from langgraph.runtime import ExecutionInfo, Runtime
49
51
  from langgraph.types import Command, PregelExecutableTask, RetryPolicy, TimeoutPolicy
@@ -571,6 +573,23 @@ def _checkpoint_ns_for_parent_command(ns: str) -> str:
571
573
  return NS_SEP.join(parts)
572
574
 
573
575
 
576
+ def _reset_interrupt_counter(config: RunnableConfig) -> RunnableConfig:
577
+ # A retry reruns the node from its first line, so its interrupt() calls count
578
+ # from the first again to reuse the answers its task already has, rather than
579
+ # asking again under an id the next resume can't match.
580
+ scratchpad = config[CONF].get(CONFIG_KEY_SCRATCHPAD)
581
+ if scratchpad is None:
582
+ return config
583
+ return patch_configurable(
584
+ config,
585
+ {
586
+ CONFIG_KEY_SCRATCHPAD: replace(
587
+ scratchpad, interrupt_counter=LazyAtomicCounter()
588
+ )
589
+ },
590
+ )
591
+
592
+
574
593
  def run_with_retry(
575
594
  task: PregelExecutableTask,
576
595
  retry_policy: Sequence[RetryPolicy] | None,
@@ -681,6 +700,7 @@ def run_with_retry(
681
700
  )
682
701
  # signal subgraphs to resume (if available)
683
702
  config = patch_configurable(config, {CONFIG_KEY_RESUMING: True})
703
+ config = _reset_interrupt_counter(config)
684
704
 
685
705
 
686
706
  async def arun_with_retry(
@@ -829,6 +849,7 @@ async def arun_with_retry(
829
849
  )
830
850
  # signal subgraphs to resume (if available)
831
851
  config = patch_configurable(config, {CONFIG_KEY_RESUMING: True})
852
+ config = _reset_interrupt_counter(config)
832
853
 
833
854
 
834
855
  def _return_value(task: PregelExecutableTask) -> Any:
@@ -50,6 +50,7 @@ from langgraph._internal._constants import (
50
50
  CONFIG_KEY_CHECKPOINT_MAP,
51
51
  CONFIG_KEY_CHECKPOINT_NS,
52
52
  CONFIG_KEY_STREAM,
53
+ CONFIG_KEY_STRICT_RESUME,
53
54
  CONFIG_KEY_TASK_ID,
54
55
  INTERRUPT,
55
56
  NS_SEP,
@@ -81,6 +82,7 @@ _CONF_DROPLIST = frozenset(
81
82
  CONFIG_KEY_CHECKPOINT_ID,
82
83
  CONFIG_KEY_CHECKPOINT_NS,
83
84
  CONFIG_KEY_TASK_ID,
85
+ CONFIG_KEY_STRICT_RESUME,
84
86
  ),
85
87
  )
86
88
 
@@ -33,6 +33,7 @@ from xxhash import xxh3_128_hexdigest
33
33
 
34
34
  from langgraph._internal._cache import default_cache_key
35
35
  from langgraph._internal._constants import INTERRUPT as _INTERRUPT_KEY
36
+ from langgraph._internal._constants import NS_SEP
36
37
  from langgraph._internal._fields import get_cached_annotated_keys, get_update_as_tuples
37
38
  from langgraph._internal._retry import default_retry_on
38
39
  from langgraph._internal._typing import MISSING, DeprecatedKwargs
@@ -579,6 +580,15 @@ def omit_payload(_value: Any) -> dict[str, Any]:
579
580
  _DEFAULT_INTERRUPT_ID = "placeholder-id"
580
581
 
581
582
 
583
+ def _interrupt_id(ns: str, answered: int) -> str:
584
+ # Keyed by how many answers the task already has, the slot this interrupt's
585
+ # answer fills; call order isn't stable across parallel calls in one task.
586
+ # With none it's the bare namespace hash older versions gave every
587
+ # interrupt, so saved ids still match. The suffix can't form another task's
588
+ # namespace, whose segments all contain ":".
589
+ return xxh3_128_hexdigest((f"{ns}{NS_SEP}{answered}" if answered else ns).encode())
590
+
591
+
582
592
  @final
583
593
  @dataclass(init=False, slots=True)
584
594
  class Interrupt(Generic[ResponseT]):
@@ -641,7 +651,7 @@ class Interrupt(Generic[ResponseT]):
641
651
  ) -> Interrupt[ResponseT]:
642
652
  return cls(
643
653
  value=value,
644
- id=xxh3_128_hexdigest(ns.encode()),
654
+ id=_interrupt_id(ns, 0),
645
655
  response_schema=response_schema,
646
656
  )
647
657
 
@@ -1037,9 +1047,11 @@ def interrupt(
1037
1047
  # no resume value found
1038
1048
  raise GraphInterrupt(
1039
1049
  (
1040
- Interrupt.from_ns(
1050
+ Interrupt(
1041
1051
  value=value,
1042
- ns=conf[CONFIG_KEY_CHECKPOINT_NS],
1052
+ id=_interrupt_id(
1053
+ conf[CONFIG_KEY_CHECKPOINT_NS], len(scratchpad.resume)
1054
+ ),
1043
1055
  response_schema=adapter.json_schema() if adapter else response_schema,
1044
1056
  ),
1045
1057
  )
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "langgraph"
7
- version = "1.2.19"
7
+ version = "1.2.20"
8
8
  description = "Building stateful, multi-actor applications with LLMs"
9
9
  authors = []
10
10
  requires-python = ">=3.10"
@@ -16,7 +16,7 @@ from langgraph_sdk.schema import StreamPart
16
16
  from pydantic import BaseModel
17
17
  from typing_extensions import TypedDict
18
18
 
19
- from langgraph._internal._constants import CONFIG_KEY_STREAM
19
+ from langgraph._internal._constants import CONFIG_KEY_STREAM, CONFIG_KEY_STRICT_RESUME
20
20
  from langgraph.errors import GraphInterrupt
21
21
  from langgraph.graph import END, START, MessagesState, StateGraph, add_messages
22
22
  from langgraph.pregel import Pregel
@@ -1360,6 +1360,7 @@ def test_sanitize_config():
1360
1360
  "checkpoint_map": {"key": "value"}, # Should be dropped
1361
1361
  "checkpoint_id": "123", # Should be dropped
1362
1362
  "checkpoint_ns": "ns", # Should be dropped
1363
+ CONFIG_KEY_STRICT_RESUME: True, # Should be dropped
1363
1364
  }
1364
1365
  }
1365
1366
  sanitized = remote._sanitize_config(config_with_drops)