fix: prevent async functional API from double-consuming interrupt resume values#6739
Open
abhigyan631 wants to merge 4 commits intolangchain-ai:mainfrom
Open
Conversation
…ume values Fix for issue langchain-ai#6660. In async mode, both parent and child scratchpads were capturing references to the same resume tuple in pending_writes. When both attempted to consume the value, it caused iterations to be skipped (e.g., output 1, 123, 12345 instead of expected 1, 12, 123, 1234, 12345). The fix ensures child scratchpads always delegate to parent for null_resume, preventing the double-consumption race condition. Only the parent scratchpad now 'owns' the resume value lookup.
Collaborator
|
Do you happen to have a test case that reproduces this? |
Author
Yes, I've added a regression test case, test_repro_issue_6660.py, that reproduces the reproduction scenario (5 async tasks/resumes). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for issue #6660.
In async mode, both parent and child scratchpads were capturing references to the same resume tuple in pending_writes. When both attempted to consume the value, it caused iterations to be skipped (e.g., output 1, 123, 12345 instead of expected 1, 12, 123, 1234, 12345).
The fix ensures child scratchpads always delegate to parent for null_resume, preventing the double-consumption race condition. Only the parent scratchpad now 'owns' the resume value lookup.
Thank you for contributing to LangGraph! Follow these steps to mark your pull request as ready for review. If any of these steps are not completed, your PR will not be considered for review.
PR title: Follows the format: {TYPE}({SCOPE}): {DESCRIPTION}
{TYPE}values:{SCOPE}values (optional):PR message: Delete this entire checklist and replace with
Add tests and docs: If you're adding a new integration, you must include:
docs/docs/integrationsdirectory.Lint and test: Run
make format,make lintandmake testfrom the root of the package(s) you've modified. We will not consider a PR unless these three are passing in CI. See contribution guidelines for more.Additional guidelines:
pyproject.tomlfiles (even optional ones) unless they are required for unit tests.