2.4

interrupt() and Command(resume): the resume index and interrupt ids

A resume reruns the node from its first line, model calls too, and matches answers by position, so keep model calls out of interrupting nodes and resume by id map.

Your graph asks two people at once: a traveller in one branch and an approver in another. Each node first asks the model to write its question. Both questions reach your UI. The approver answers first, and your server sends Command(resume="OK"). LangGraph raises RuntimeError, and nothing resumes. When you send both answers as a map, it works, and your bill shows the model wrote the same questions again.

When you finish this section, you can trace a resume through interrupt() line by line and predict which answer each call gets. You can also resume two waiting nodes in one call, and count the model calls that a resume repeats.

What interrupt() does on each call

Resume list: the list of answers that one task has received so far, saved as a write on the channel __resume__.

interrupt() keeps a counter in the scratchpad of its task. On each call it takes the next index and tries three sources in order:

  1. If the resume list of the task has an answer at this index, it returns that answer. This is the replay of an earlier question.
  2. Otherwise, if the resume command carried one answer for the whole graph, it appends that answer to the list, saves the list, and returns it.
  3. Otherwise, it raises GraphInterrupt with a new Interrupt, and the node stops.

Interrupt id: the id of one question. It is an xxh3 hash of the task namespace, with |n added for the nth unanswered question of that task.

When a task raises GraphInterrupt, the runner saves the question and the resume list as writes of that task. The id needs no storage. The loop recomputes it from the namespace and the number of answers. The saver stores the question as a write on __interrupt__ with index -3, and each answer on __resume__ with index -4.

Three calls on one thread, captured

The capture graph runs ask, approve, and other in parallel after START, and then after. It uses Qwen3 4B on the x86 server guest at temperature 0. ask asks the model for a question, calls interrupt(), asks the model for a second question, and calls interrupt() again. approve asks the model for one question and calls interrupt() once. other calls the weather tool and the model, and never interrupts. Each node logs its first line with its namespace and its resume list, and logs each model call.

The first invoke returned two interrupts. other ran and finished, and its writes were saved:

outputrun 1, two interrupts and the recomputed idsFull log
  returned interrupt id=462dc352bc169ed50a32e43c579712fb value={'q': 'Which city would you like to visit?'}
  returned interrupt id=11314d20c136a4a3ec3a8a26c24243c9 value={'q': 'Could you please approve a travel budget of 900 EUR for the upcoming business trip to Berlin?'}
…
  recompute id for ask: xxh3_128(task_checkpoint_ns='ask:db8df5fb-7f77-0ac1-61de-e4a38b97c8a0') = 462dc352bc16... matches=True
  recompute id for approve: xxh3_128(task_checkpoint_ns='approve:56f9f439-6fe7-44ef-ec89-762fd2b36cf4') = 11314d20c136... matches=True

A resume with one plain value raised, and no node and no model call ran. The loop counts the pending interrupts, and with more than one it requires a map from id to answer:

outputrun 2a, one answer for two questionsFull log
## run 2a: Command(resume='yes') without an id while 2 interrupts are pending
  raises RuntimeError: When there are multiple pending interrupts, you must specify the interrupt id when resuming. Docs: https://docs.langchain.com/oss/python/lan

The map form worked. Both nodes ran again from their first line, and both called the model again before they reached interrupt(). approve got OK and finished. ask got A1 for its first question, asked the model for its second, and stopped there with a new id. other did not run again. The loop reapplied its saved writes:

outputrun 2b, a map of answers by idFull log
## run 2b: Command(resume={ask_id: 'A1', approve_id: 'OK'})
…
    {"node": "ask", "event": "enter (first line)", "ns": "ask:db8df5fb-7f77-0ac1-61de-e4a38b97c8a0", "scratchpad.resume": ["A1"], "null_resume": null}
    {"node": "ask", "event": "model call -> 'Which city would you like to visit?'", "model_s": 1.16}
    {"node": "ask", "event": "interrupt #0 returned 'A1'"}
…
  tick step=1 returns=True to_run=['approve', 'ask'] reapplied(no rerun)=['other']
  returned interrupt id=177b6fc6979f90e1a13103fec68d96fb value={'q': 'How many nights will the traveller stay at A1?'}
  second interrupt id expected = xxh3_128(ns + '|1') = 177b6fc6979f... matches=True

The third call, Command(resume='A2'), needed no id, because one question was left. ask ran a third time. It asked the model for its first question again and replayed A1 from the list. Then it asked for its second question again and got A2 from the command. Figure 2.6 draws the three calls.

Fig. 2.6three calls that answer three questions in two parallel nodestimeline
Three calls that answer three questions in two parallel nodes A grid of four nodes against four calls on one thread with InMemorySaver and Qwen3 4B on the x86 server guest. ask, approve, and other run in parallel after START, and after runs last. ask and approve each ask the model for a question before they call interrupt. Call 1 starts the run: ask stops at its first interrupt with id 462dc352, approve stops with id 11314d20, and other finishes. Call 2a resumes with one plain value and raises RuntimeError, because two interrupts wait, and makes no model call. Call 2b resumes with a map from id to answer: approve asks the model again, gets OK, and finishes. ask asks the model again, replays its first answer, asks for its second question, and stops with id 177b6fc6. other does not run, because its saved writes are reapplied. Call 3 resumes with A2: ask runs a third time with two model calls and finishes, and after runs. The calls made 3, 0, 3, and 3 model calls, 9 for five prompts. The thread holds 4 checkpoints, steps -1, 0, 1, 2. CALL resume value run 1 invoke(input) run 2a 'yes' run 2b {id: answer} run 3 'A2' ask approve other after enter, list [] 1 model call call #0 stops id 462dc352 enter, list [] 1 model call call #0 stops id 11314d20 runs once 1 model call done writes saved - enter, list [A1] 2 model calls #0 returns A1 #1 stops 177b6fc6 enter, list [OK] 1 model call #0 returns OK done not run 0 model calls saved writes reapplied - enter, list [A1] 2 model calls #0 replays A1 #1 gets A2, done - - runs 1 model call done Runtime Error 2 waiting no node ran model calls checkpoints 3 step -1, step 0 0 none 3 none 3 step 1, step 2 answers saved as writes on the step 0 checkpoint stops at an interrupt finishes writes reapplied, no run list: the resume list on entry, 9 model calls for five prompts in all
Each call reran the waiting nodes and their model calls from the first line, replayed saved answers by index, and never ran the finished node other again. Columns are the calls in order, and rows are the four nodes. Amber cells stop at an interrupt, with its id, teal cells finish, and the dashed cell reapplied saved writes. The list in each cell is the resume list the node saw on its first line. The bottom rows count model calls and name the checkpoints each call saved.

What the replay costs

The graph has five model prompts: two in ask, one each in approve, other, and after. The three calls made 9 model calls:

outputmodel calls per call of the graphFull log
## model calls per invocation: {'run 1': 3, 'run 2a': 0, 'run 2b': 3, 'run 3': 3}

The first question of ask went to the model three times, and its second question and the question of approve twice each. At temperature 0 the replayed questions came back word for word the same. A model that samples can write a different question on the replay. The answer still goes to the same index, so your user can answer one question and the node then sees another.

No new checkpoint inside a superstep

Three calls on the thread made four checkpoints, not six:

outputthe checkpoint history after three callsFull log
## checkpoint history (newest first)
  step=2 source=loop next=() id=..bc1c0b7b902f
  step=1 source=loop next=('after',) id=..9a14716dbcea
  step=0 source=loop next=('ask', 'approve', 'other') id=..1ca1bd022200
  step=-1 source=input next=('__start__',) id=..88027e62558c

Run 2b ended with ask still waiting, so the superstep of step 1 was not done. The answers and the new question were saved as writes on checkpoint 1ca1bd022200, next to the writes of other. A checkpoint appears only when every task of the superstep has finished. So a time-travel tool that lists checkpoints shows no point between two answers to the same node.

What to do

Read the pending interrupts from get_state(config).tasks, and answer with Command(resume={id: value}). The loop reads a dict as a map when every key is an xxh3 hex id, whatever the number of pending interrupts. We did not run the map form with one interrupt. Use it always, so a second branch with a question does not break your server.

Move each model call that writes a question into its own node, before the node that calls interrupt(). That node finishes, its writes are saved, and a resume does not run it again, as other shows. The question then stays the same on every replay, and you pay for it once.

Keep the interrupt() calls of a node in the same order on every run, and do not skip one on a condition that can change. The answer goes to an index, not to a question.

The interrupt id is a stable name for a question. It depends only on the task namespace, and section 2.3 measured that namespace across a crash and a new process. Use the id as the key of the question in your UI and your database.

LangChain (Python): langchain, langchain-core, langgraph, deepagents, langsmith 1.5.0 · c2f4036 · 2026-11-11 · Edition 2026.11