If the state of the parent graph is updated, then the state of the subgraph will be lost #633

Closed
opened 2026-02-20 17:41:02 -05:00 by yindo · 5 comments
Owner

Originally created by @egortaran on GitHub (May 19, 2025).

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

from typing import TypedDict

from langchain_core.runnables import RunnableConfig
from langgraph.checkpoint.memory import MemorySaver
from langgraph.constants import START
from langgraph.graph import END, StateGraph


class State(TypedDict):
    foo: bool
    bar: bool


# Preparing subgraph
def subgraph_node_1(state: State) -> State:
    state["foo"] = True
    print("Executing `subgraph_node_1`")
    return state


def subgraph_node_2(state: State) -> State:
    print("Executing `subgraph_node_2`")
    return state


subgraph_builder = StateGraph(State)
subgraph_builder.add_node("subgraph_node_1", subgraph_node_1)
subgraph_builder.add_node("subgraph_node_2", subgraph_node_2)

subgraph_builder.add_edge(START, "subgraph_node_1")
subgraph_builder.add_edge("subgraph_node_1", "subgraph_node_2")
subgraph_builder.add_edge("subgraph_node_2", END)

subgraph = subgraph_builder.compile(
    interrupt_after=[
        "subgraph_node_1",
        "subgraph_node_2",
    ],
)

# Preparing parent graph
builder = StateGraph(State)


def node1(state: State) -> State:
    print("Executing `node1`")
    return state


def node3(state: State) -> State:
    print("Executing `node3`")
    return state


builder.add_node("node1", node1)
builder.add_node("node2", subgraph)
builder.add_node("node3", node3)

builder.add_edge(START, "node1")
builder.add_edge("node1", "node2")
builder.add_edge("node2", "node3")
builder.add_edge("node3", END)


# Graph executing
checkpointer = MemorySaver()
config = RunnableConfig(configurable={"thread_id": "1"})
graph = builder.compile(
    checkpointer=checkpointer,
    interrupt_after=["node1", "node3",],
)

for event in graph.stream({"foo": False, "bar": False}, config=config, stream_mode="updates", subgraphs=True):
    print(event)

print("*" * 10, "\n\n")


for event in graph.stream(None, config, subgraphs=True):
    print(event)

print("*" * 10, "\n\n")

# Update graph state
new_config = graph.update_state(config, {"bar": True})

for event in graph.stream(None, new_config, subgraphs=True):
    print(event)

print("*" * 10, "\n\n")


new_state2 = graph.get_state(config)
print("graph_state.value =", new_state2.values)

Error Message and Stack Trace (if applicable)


Description

I work with graphs and subgraphs that can be interrupted. When I update the state of the parent graph after interrupting a node in the subgraph, two issues occur:

  • The parent graph’s state doesn’t reflect the latest execution result from the subgraph’s node.
  • The subgraph restarts from the beginning instead of resuming from where it was interrupted.

I expect to see:

  1. Executing node1
  2. Executing subgraph_node_1
  3. [Updating the graph state]
  4. Executing subgraph_node_2
  5. graph_state.value = {'foo': True, 'bar': True}

Instead, it does:

  1. Executing node1
  2. Executing subgraph_node_1
  3. [Updating the graph state]
  4. Executing subgraph_node_1
  5. graph_state.value = {'foo': False, 'bar': True}

Also I drew the graph as a PNG image using a mermaid:

Image

System Info

System Information

OS: Linux
OS Version: #61~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 15 17:03:15 UTC 2
Python Version: 3.12.7 (main, Oct 10 2024, 15:12:39) [GCC 9.4.0]

Package Information

langchain_core: 0.3.60
langsmith: 0.3.42
langgraph_sdk: 0.1.69

Optional packages not installed

langserve

Other Dependencies

httpx: 0.28.1
jsonpatch<2.0,>=1.33: Installed. No version info available.
langsmith-pyo3: Installed. No version info available.
langsmith<0.4,>=0.1.126: Installed. No version info available.
openai-agents: Installed. No version info available.
opentelemetry-api: Installed. No version info available.
opentelemetry-exporter-otlp-proto-http: Installed. No version info available.
opentelemetry-sdk: Installed. No version info available.
orjson: 3.10.18
packaging: 24.2
packaging<25,>=23.2: Installed. No version info available.
pydantic: 2.11.4
pydantic>=2.7.4: Installed. No version info available.
pytest: Installed. No version info available.
PyYAML>=5.3: Installed. No version info available.
requests: 2.32.3
requests-toolbelt: 1.0.0
rich: Installed. No version info available.
tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
typing-extensions>=4.7: Installed. No version info available.
zstandard: 0.23.0

Originally created by @egortaran on GitHub (May 19, 2025). ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use GitHub Discussions. - [x] I added a clear and detailed title that summarizes the issue. - [x] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [x] I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue. ### Example Code ```python from typing import TypedDict from langchain_core.runnables import RunnableConfig from langgraph.checkpoint.memory import MemorySaver from langgraph.constants import START from langgraph.graph import END, StateGraph class State(TypedDict): foo: bool bar: bool # Preparing subgraph def subgraph_node_1(state: State) -> State: state["foo"] = True print("Executing `subgraph_node_1`") return state def subgraph_node_2(state: State) -> State: print("Executing `subgraph_node_2`") return state subgraph_builder = StateGraph(State) subgraph_builder.add_node("subgraph_node_1", subgraph_node_1) subgraph_builder.add_node("subgraph_node_2", subgraph_node_2) subgraph_builder.add_edge(START, "subgraph_node_1") subgraph_builder.add_edge("subgraph_node_1", "subgraph_node_2") subgraph_builder.add_edge("subgraph_node_2", END) subgraph = subgraph_builder.compile( interrupt_after=[ "subgraph_node_1", "subgraph_node_2", ], ) # Preparing parent graph builder = StateGraph(State) def node1(state: State) -> State: print("Executing `node1`") return state def node3(state: State) -> State: print("Executing `node3`") return state builder.add_node("node1", node1) builder.add_node("node2", subgraph) builder.add_node("node3", node3) builder.add_edge(START, "node1") builder.add_edge("node1", "node2") builder.add_edge("node2", "node3") builder.add_edge("node3", END) # Graph executing checkpointer = MemorySaver() config = RunnableConfig(configurable={"thread_id": "1"}) graph = builder.compile( checkpointer=checkpointer, interrupt_after=["node1", "node3",], ) for event in graph.stream({"foo": False, "bar": False}, config=config, stream_mode="updates", subgraphs=True): print(event) print("*" * 10, "\n\n") for event in graph.stream(None, config, subgraphs=True): print(event) print("*" * 10, "\n\n") # Update graph state new_config = graph.update_state(config, {"bar": True}) for event in graph.stream(None, new_config, subgraphs=True): print(event) print("*" * 10, "\n\n") new_state2 = graph.get_state(config) print("graph_state.value =", new_state2.values) ``` ### Error Message and Stack Trace (if applicable) ```shell ``` ### Description I work with graphs and subgraphs that can be interrupted. When I update the state of the parent graph after interrupting a node in the subgraph, two issues occur: - The parent graph’s state doesn’t reflect the latest execution result from the subgraph’s node. - The subgraph restarts from the beginning instead of resuming from where it was interrupted. I expect to see: 1. Executing node1 2. Executing subgraph_node_1 3. [Updating the graph state] 4. Executing **subgraph_node_2** 5. graph_state.value = {'foo': **True**, 'bar': True} Instead, it does: 1. Executing node1 2. Executing subgraph_node_1 3. [Updating the graph state] 4. Executing **subgraph_node_1** 5. graph_state.value = {'foo': **False**, 'bar': True} Also I drew the graph as a PNG image using a mermaid: ![Image](https://github.com/user-attachments/assets/214ef4e9-d289-4d1b-85db-efbb1064bc35) ### System Info System Information ------------------ > OS: Linux > OS Version: #61~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 15 17:03:15 UTC 2 > Python Version: 3.12.7 (main, Oct 10 2024, 15:12:39) [GCC 9.4.0] Package Information ------------------- > langchain_core: 0.3.60 > langsmith: 0.3.42 > langgraph_sdk: 0.1.69 Optional packages not installed ------------------------------- > langserve Other Dependencies ------------------ > httpx: 0.28.1 > jsonpatch<2.0,>=1.33: Installed. No version info available. > langsmith-pyo3: Installed. No version info available. > langsmith<0.4,>=0.1.126: Installed. No version info available. > openai-agents: Installed. No version info available. > opentelemetry-api: Installed. No version info available. > opentelemetry-exporter-otlp-proto-http: Installed. No version info available. > opentelemetry-sdk: Installed. No version info available. > orjson: 3.10.18 > packaging: 24.2 > packaging<25,>=23.2: Installed. No version info available. > pydantic: 2.11.4 > pydantic>=2.7.4: Installed. No version info available. > pytest: Installed. No version info available. > PyYAML>=5.3: Installed. No version info available. > requests: 2.32.3 > requests-toolbelt: 1.0.0 > rich: Installed. No version info available. > tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available. > typing-extensions>=4.7: Installed. No version info available. > zstandard: 0.23.0
yindo closed this issue 2026-02-20 17:41:02 -05:00
Author
Owner

@egortaran commented on GitHub (May 19, 2025):

I’m not sure why the LangGraph version isn’t displayed when I run python -m langchain_core.sys_info, so I’m providing the version details manually pip show langgraph:

Name: langgraph
Version: 0.4.5
Summary: Building stateful, multi-actor applications with LLMs
Home-page: 
Author: 
Author-email: 
License: MIT
Location: /home/taran/PycharmProjects/PythonProject/.venv/lib/python3.12/site-packages
Requires: langchain-core, langgraph-checkpoint, langgraph-prebuilt, langgraph-sdk, pydantic, xxhash
Required-by: 
@egortaran commented on GitHub (May 19, 2025): I’m not sure why the LangGraph version isn’t displayed when I run `python -m langchain_core.sys_info`, so I’m providing the version details manually `pip show langgraph`: ``` Name: langgraph Version: 0.4.5 Summary: Building stateful, multi-actor applications with LLMs Home-page: Author: Author-email: License: MIT Location: /home/taran/PycharmProjects/PythonProject/.venv/lib/python3.12/site-packages Requires: langchain-core, langgraph-checkpoint, langgraph-prebuilt, langgraph-sdk, pydantic, xxhash Required-by: ```
Author
Owner

@michalgala commented on GitHub (May 25, 2025):

try adding checkpointer=True in the subgraph compilation

subgraph = subgraph_builder.compile(
    checkpointer=True,
    interrupt_after=[
        "subgraph_node_1",
        "subgraph_node_2",
    ],
)
@michalgala commented on GitHub (May 25, 2025): try adding _checkpointer=True_ in the subgraph compilation ``` subgraph = subgraph_builder.compile( checkpointer=True, interrupt_after=[ "subgraph_node_1", "subgraph_node_2", ], ) ```
Author
Owner

@egortaran commented on GitHub (May 27, 2025):

Thanks for the answer, @michalgala! Your comment solved the problem in half, which is already good!
The issue persists when retrieving the graph state values. That is, if I apply your changes, my log will be:

Executing `node1`
((), {'node1': {'foo': False, 'bar': False}})
((), {'__interrupt__': ()})
********** 


Executing `subgraph_node_1`
(('node2',), {'subgraph_node_1': {'foo': True, 'bar': False}})
((), {'__interrupt__': ()})
********** 


Executing `subgraph_node_2`
(('node2',), {'subgraph_node_2': {'foo': True, 'bar': False}})
((), {'__interrupt__': ()})
********** 


graph_state.value = {'foo': False, 'bar': True}

In the "Executing subgraph_node_2" I expected to see:

{'subgraph_node_2': {'foo': True, 'bar': True}}

Instead, it does:

{'subgraph_node_2': {'foo': True, 'bar': False}}

Also in the last print I expected to see:

graph_state.value = {'foo': True, 'bar': True}

Instead, it does:

graph_state.value = {'foo': False, 'bar': True}
@egortaran commented on GitHub (May 27, 2025): Thanks for the answer, @michalgala! Your comment solved the problem in half, which is already good! The issue persists when retrieving the graph state values. That is, if I apply your changes, my log will be: ``` Executing `node1` ((), {'node1': {'foo': False, 'bar': False}}) ((), {'__interrupt__': ()}) ********** Executing `subgraph_node_1` (('node2',), {'subgraph_node_1': {'foo': True, 'bar': False}}) ((), {'__interrupt__': ()}) ********** Executing `subgraph_node_2` (('node2',), {'subgraph_node_2': {'foo': True, 'bar': False}}) ((), {'__interrupt__': ()}) ********** graph_state.value = {'foo': False, 'bar': True} ``` ___ In the "**Executing subgraph_node_2**" I expected to see: ``` {'subgraph_node_2': {'foo': True, 'bar': True}} ``` Instead, it does: ``` {'subgraph_node_2': {'foo': True, 'bar': False}} ``` ___ Also in the last print I expected to see: ``` graph_state.value = {'foo': True, 'bar': True} ``` Instead, it does: ``` graph_state.value = {'foo': False, 'bar': True} ```
Author
Owner

@michalgala commented on GitHub (May 27, 2025):

Yes, now we have the same issue, see here

There is a workaround, you could use interrupt(), and resume your graph with Command(resume=..)

@michalgala commented on GitHub (May 27, 2025): Yes, now we have the same issue, [see here](https://github.com/langchain-ai/langgraph/issues/4796) There is a workaround, you could use interrupt(), and resume your graph with Command(resume=..)
Author
Owner

@sydney-runkle commented on GitHub (Jun 11, 2025):

Closing this as a dupe of https://github.com/langchain-ai/langgraph/issues/4866, we'll provide updates there!

@sydney-runkle commented on GitHub (Jun 11, 2025): Closing this as a dupe of https://github.com/langchain-ai/langgraph/issues/4866, we'll provide updates there!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#633