`interrupt_before` re-interrupts forever after a state key is removed
Checked other resources
- This is a bug, not a usage question.
- I added a clear and descriptive title that summarizes this issue.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangGraph rather than my code.
- The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package).
- I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.
Example Code
import operator
from typing import Annotated
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import START, StateGraph
from typing_extensions import TypedDict
class Before(TypedDict, total=False):
log: Annotated[list[str], operator.add]
note: str
class After(TypedDict, total=False): # the same state with `note` removed
log: Annotated[list[str], operator.add]
def first_before(state):
return {"log": ["first"], "note": "x"}
def first_after(state):
return {"log": ["first"]}
def last(state):
return {"log": ["last"]}
def build(schema, first, saver):
builder = StateGraph(schema)
builder.add_node("first", first)
builder.add_node("last", last)
builder.add_edge(START, "first")
builder.add_edge("first", "last")
return builder.compile(checkpointer=saver, interrupt_before=["last"])
saver = InMemorySaver()
config = {"configurable": {"thread_id": "1"}}
build(Before, first_before, saver).invoke({"log": []}, config) # pauses before "last"
graph = build(After, first_after, saver) # redeploy without `note`
for _ in range(3):
print(graph.invoke(None, config)["log"], graph.get_state(config).next)Output:
['first'] ('last',)
['first'] ('last',)
['first'] ('last',)Expected ['first', 'last'] () on the first resume.
Error Message and Stack Trace (if applicable)
None. That is the problem: each resume returns normally and the thread is paused before last again.
Description
When a thread resumes, _first() marks the breakpoint as seen for the channels the current graph
has (pregel/_loop.py#L948):
for k in self.channels:
if k in self.checkpoint["channel_versions"]:
...
self.checkpoint["versions_seen"][INTERRUPT][k] = versionshould_interrupt() then checks every channel in the checkpoint
(pregel/_algo.py#L155):
any_updates_since_prev_interrupt = any(
version > seen.get(chan, null_version)
for chan, version in checkpoint["channel_versions"].items()
)A stored channel the graph no longer has (here note) is never marked as seen, so
any_updates_since_prev_interrupt is always true and interrupt_before fires again on every
resume. The stale version is carried into every later checkpoint, so this is not limited to threads
that were paused at the breakpoint at deploy time. A thread paused in interrupt() elsewhere also
gets stuck at the first interrupt_before it reaches after the change. interrupt_after is not
affected.
The backward-compatibility guide does list removing a state key as a breaking change. But the
failure here is not the key failing to load: the thread loads and runs normally, and only a static
breakpoint turns into an infinite loop with no error. One common case is a
create_react_agent(..., state_schema=..., interrupt_before=["tools"]) tool-approval flow after a
custom state field is dropped. The human approves the tool call, the tool never runs, and the
approval is requested again, indefinitely.
Suggested fix: mark every stored channel as seen on resume, not only the graph's.
- for k in self.channels:
- if k in self.checkpoint["channel_versions"]:
- version = self.checkpoint["channel_versions"][k]
- self.checkpoint["versions_seen"][INTERRUPT][k] = version
+ for k, version in self.checkpoint["channel_versions"].items():
+ self.checkpoint["versions_seen"][INTERRUPT][k] = versionFor channels the graph has, this is exactly the current behaviour; channels it doesn't have can never be updated again, so marking them seen changes nothing else. With this change:
- the
libs/langgraphsuite (NO_DOCKER=true) gives the same result before and after: 2027 passed, 4 skipped; - two regression tests, one for a thread paused at the breakpoint and one that reaches it later,
fail on
mainand pass with the fix.
I have the fix and both tests ready. Could a maintainer assign this issue to me so I can open the PR?
System Info
langgraph 1.2.11 (also reproduced on 1.0.0 and 1.1.0, and on main at aa742fb), langgraph-checkpoint
4.2.0, Python 3.13, macOS. The same result with SqliteSaver.
Source: langchain-ai/langgraph