-
Notifications
You must be signed in to change notification settings - Fork 15.9k
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
core: Fix AsyncCallbackManager
to honor run_inline
attribute and prevent context loss
#26885
Merged
eyurtsev
merged 14 commits into
langchain-ai:master
from
parambharat:fix/async-callback-context
Oct 7, 2024
Merged
core: Fix AsyncCallbackManager
to honor run_inline
attribute and prevent context loss
#26885
eyurtsev
merged 14 commits into
langchain-ai:master
from
parambharat:fix/async-callback-context
Oct 7, 2024
Conversation
This file contains 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
…hain-ai#23909) - Add failing test to demonstrate issue fixed in PR langchain-ai#23909 - Show `AsyncCallbackManager` doesn't honor run_inline attribute - Use `shared_stack` to capture non-deterministic execution order - Illustrate why `contextvars` alone can't detect this issue - Test expects to fail until fix for langchain-ai#23909 is implemented
- Separate inline and non-inline handlers in `on_llm_start` and `on_chat_model_start` - Execute inline handlers sequentially - Run non-inline handlers concurrently - Maintain context integrity for stateful handlers - Address issue langchain-ai#23909 and fix test in PR langchain-ai#26857
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
dosubot
bot
added
size:L
This PR changes 100-499 lines, ignoring generated files.
Ɑ: core
Related to langchain-core
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
labels
Sep 26, 2024
hi @eyurtsev . Just checking in. Any update on merging this here ? |
eyurtsev
reviewed
Oct 4, 2024
eyurtsev
reviewed
Oct 4, 2024
eyurtsev
approved these changes
Oct 4, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@parambharat please verify that you're OK with the changes, if so I'll merge on Monday
dosubot
bot
added
the
lgtm
PR looks good. Use to confirm that a PR is ready for merging.
label
Oct 4, 2024
4 tasks
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.
Description
This PR fixes the context loss issue in
AsyncCallbackManager
, specifically inon_llm_start
andon_chat_model_start
methods. It properly honors therun_inline
attribute of callback handlers, preventing race conditions and ordering issues.Key changes:
These changes are implemented in
AsyncCallbackManager
rather thanahandle_event
because the issue occurs at the prompt and message_list levels, not within individual events.Testing
Related Issues
run_inline
is honored in AsyncCallback Handler #23909Dependencies
No new dependencies are required.
@eyurtsev: This PR implements the discussed changes to respect
run_inline
inAsyncCallbackManager
. Please review and advise on any needed changes.Twitter handle: @parambharat