fix(langgraph): yield task_result events with errors in single debug stream mode#6984
Open
Br1an (Br1an67) wants to merge 1 commit intolangchain-ai:mainfrom
Open
fix(langgraph): yield task_result events with errors in single debug stream mode#6984Br1an (Br1an67) wants to merge 1 commit intolangchain-ai:mainfrom
Br1an (Br1an67) wants to merge 1 commit intolangchain-ai:mainfrom
Conversation
…stream mode In the runner fast path (single task, no waiter), yield control back to the caller before raising the exception. This allows the main loop to drain the stream queue and emit the task_result event containing the error before the exception propagates. The concurrent path already yields before _panic_or_proceed, which is why stream_mode=["debug", "messages"] worked correctly. Fixes langchain-ai#5764
Open
4 tasks
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.
Description: When using
stream_mode="debug"(single mode),task_resultevents containing errors were not yielded before the exception was raised. This happened because the runner's fast path (single task, no waiter/timeout) raised the exception immediately after committing the error writes without yielding control back to the caller to drain the stream queue.The fix adds a
yieldin the fast path error handling of bothtick()andatick(), matching the behavior of the concurrent path which already yields before_panic_or_proceed. This allows the main loop to call_output()and emit thetask_resultevent before the exception propagates.With
stream_mode=["debug", "messages"]the issue didn't occur becauseget_waiteris not None when "messages" is in stream_modes, bypassing the fast path.Fixes #5764
Dependencies: None