Skip to content
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

Interrupt using the same old question, when invoked second time. #3275

Open
4 tasks done
Saisiva123 opened this issue Feb 1, 2025 · 6 comments
Open
4 tasks done

Interrupt using the same old question, when invoked second time. #3275

Saisiva123 opened this issue Feb 1, 2025 · 6 comments
Labels
question Further information is requested

Comments

@Saisiva123
Copy link

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

def ask_user_node(state: LookupState) -> Command[Literal['lookup_node']]:
       
        user_response = interrupt(state['messages'][-1].content) # intead of taking the new message content its taking the old value that it has already shown to the user.

        if user_response:
            return Command(goto='lookup_node',
                           update={'messages': [HumanMessage(content=user_response, name="User_Response")]})

Error Message and Stack Trace (if applicable)

Description

I had a node that has interrupt and this node might be called multiple times, to collect information from the user. When interrupt is invoked for the second time it shows the previous question instead of showing the new question to user.

System Info

python -m langchain_core.sys_info

@Saisiva123 Saisiva123 changed the title Interrupt using the same old question even invoked second time. Interrupt using the same old question when invoked second time. Feb 1, 2025
@Saisiva123 Saisiva123 changed the title Interrupt using the same old question when invoked second time. Interrupt using the same old question, when invoked second time. Feb 1, 2025
@vbarda
Copy link
Collaborator

vbarda commented Feb 1, 2025

This has already been answered here #3072

if you’re still having issues on the latest version of thr library, please provide a https://stackoverflow.com/help/minimal-reproducible-example

@vbarda vbarda added the invalid This doesn't seem right label Feb 1, 2025
@Saisiva123
Copy link
Author

Saisiva123 commented Feb 1, 2025

@vbarda That's a different one which was raised by me, where interrupt is not actually getting interrupted for the second time.

Now that is working fine. It is getting interrupted for the second time which is good, that has been resolved in #3072 as you said, but here the new issue is that, instead of showing new question/value to the user when interrupted for the second time, its showing the same old value to the user.

Ideal scenario should be, when the interrupt invoked for the second time, it should show the new/updated question to the user instead of still showing the old question, what do you think?

@vbarda
Copy link
Collaborator

vbarda commented Feb 2, 2025

hm, i double checked using a simple example and it's working correctly for me (see below). i think it's likely that there is an application error. feel free to adapt my example to reproduce the issue

from langgraph.graph import StateGraph, START
from langgraph.types import interrupt, Command
from langgraph.checkpoint.memory import MemorySaver
from typing import TypedDict


class State(TypedDict):
    foo: str

def my_node(state: State):
    value = interrupt(f"Provide provide a new value. Previous value is: {state['foo']}")
    return {"foo": value}

checkpointer = MemorySaver()
graph = StateGraph(State).add_node(my_node).add_edge(START, "my_node").add_edge("my_node", "my_node").compile(checkpointer=checkpointer)
config = {"configurable": {"thread_id": "1"}}

for chunk in graph.stream({"foo": ""}, config):
    print(chunk)

for chunk in graph.stream(Command(resume="foo"), config):
    print(chunk)

for chunk in graph.stream(Command(resume="bar"), config):
    print(chunk)

@Saisiva123
Copy link
Author

@vbarda Can I know the version you are using, please?

@Saisiva123
Copy link
Author

Also, I tried your example as well, it's working as expected. I think there is some issue with Langgraph Studio, but not sure.

=> I see the interrupt value in the langsmith that is showing the updated value correctly.
Image

=> But at the same time in the Langgraph Studio, I see the same old message.
Image

Not sure whats happening on why Langsmith and Langgraph are showing different values

@vbarda
Copy link
Collaborator

vbarda commented Feb 3, 2025

I am using latest version of LangGraph (0.2.69). I checked the studio, and it behaves as expected for me using the example i provided above. I would suggest modifying the code example to try and reproduce the issue

Image

@vbarda vbarda added question Further information is requested and removed invalid This doesn't seem right labels Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants