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 in loop #2929

Closed
4 tasks done
vigneshmj1997 opened this issue Jan 4, 2025 · 5 comments
Closed
4 tasks done

interrupt in loop #2929

vigneshmj1997 opened this issue Jan 4, 2025 · 5 comments

Comments

@vigneshmj1997
Copy link

vigneshmj1997 commented Jan 4, 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

def ask_user(self, state):
        """Ask user question and get response from user"""
        temp = self._check_user_message(state) # Check for all Quality of LLM
        question = temp.get("message_to_user",None)
        if not question:
            raise Exception("question is None so code cannot proceed")
        response_from_user = interrupt(question)
        logger.info(f"Response from user {response_from_user}")
        return {
            "messages":[AIMessage(question),HumanMessage(response_from_user)]
        }

Error Message and Stack Trace (if applicable)

No response

Description

  • This node goes in loop so the interrupt is triggered only first time and from second time it takes the values which has been already provided to it

System Info

langgraph = "^0.2.60"
langchain-community = "^0.3.13"
langchain = "^0.3.13"
langchain-core = "^0.3.28"
langchain-openai = "^0.2.14"
langgraph-checkpoint-postgres = "^2.0.9"
langgraph-checkpoint = "^2.0.9"
langchain-chroma = "^0.1.4"

@vigneshmj1997 vigneshmj1997 changed the title I am using interrupt in my sub graph and it doesn't get updates interrupt in loop Jan 5, 2025
@shengbo-ma
Copy link

shengbo-ma commented Jan 5, 2025

Does it happen in a subgraph like #2870?

@Saisiva123
Copy link

Saisiva123 commented Jan 6, 2025

This is the exact question that I've asked few days back:
#2927

In the documentation its mentioned that its the default behavior but there should be something that actually should interrupt the graph when invoked for the second time.

@vigneshmj1997
Copy link
Author

vigneshmj1997 commented Jan 6, 2025

@Saisiva123 Could you point me to the location in the documentation where it mentions that this is the default behavior?

I’ve identified an issue in the code at this location:
The problem is that the writes variable doesn’t retain the complete value of the entire subgraph when it’s called a second time.

I suspect that updating the value of __pregel_writes in RunnableConfig might solve the issue. Do you have any ideas on how to do this?

Additionally, I’m looking for a workaround to address this problem temporarily. If you know of any, please let me know

@vigneshmj1997
Copy link
Author

Solved it have a look at this PR

its a single line change
Solution is instead of importing from the types.py
write your own function and use it

@vbarda
Copy link
Collaborator

vbarda commented Jan 10, 2025

Can someone provide a minimal reproducible example for the issue? https://stackoverflow.com/help/minimal-reproducible-example

We don't recommend using patches from the unofficial branches -- if there is an actual underlying issue we would want to solve it properly in the library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants