-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why isn’t the state updated to the last executed node on interrupt? #2586
Comments
Ahh, I found the solution. I had to access the state of subgraph like this state = graph.get_state(config, subgraphs=True)
subgraph_state = state.tasks[0].state https://langchain-ai.github.io/langgraph/how-tos/human_in_the_loop/breakpoints/#simple-usage |
This method feels overly complex, especially when retrieving the state of multi-layer nested subgraphs. I had to write recursive code to determine the deepest state, which seems cumbersome. Do you have plans to simplify this process? For instance, it would be extremely helpful to have a straightforward way to query the state of the subgraph where the last interruption occurred. |
I have the same question. I have also implemented a recursive function myself to solve this problem. |
@gbaian10 good to see that you also faced the same problem. Here is my implementation. Did you do it similarly? Any suggestions for a better way to do that? def get_deepest_state(state):
# Base case
if len(state.tasks) == 0 or not state.tasks[0].state:
return state
# Recursive case
next_level_state = state.tasks[0].state
return get_deepest_state(next_level_state) To see how it fits in the system, check this snippet of code: https://github.com/minki-j/ai-mock-coding-interview-agent/blob/main/backend/main.py#L209-L260 |
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
No response
Description
I expected the interrupt method to return the state updated up to the point of the last executed node. However, based on the example code I provided, this doesn’t seem to be the case when the node that is interrupted is in subgraph. Could you help clarify this behavior?
If I’ve misunderstood or misused the feature, please let me know. I’d appreciate any guidance on the correct usage.
Thank you for your support and for building LangGraph!
System Info
langgraph==0.2.53
langgraph-api-inmem==0.0.4
langgraph-checkpoint==2.0.6
langgraph-checkpoint-sqlite==1.0.4
langgraph-cli==0.1.55
langgraph-sdk==0.1.36
The text was updated successfully, but these errors were encountered: