You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
preserve the producer exception when the consumer also fails during producer-failure draining
continue waiting for the consumer task to settle before propagating the producer failure
keep consumer-first failure and parent-cancellation behaviour unchanged
run_producer_consumer() documents producer failures as primary while the consumer drains. Previously a secondary consumer exception raised during that drain replaced the producer exception.
Test plan
added focused regression coverage in tests/test_asyncio_tasks_primary_error.py
I traced run_producer_consumer() through its two current callers. Both dispatchers already catch and log ordinary Exceptions from on_stream, so the test's ConsumerError(Exception) cannot reach this helper through the supported Agent.as_tool() or Codex tool paths. The consumer failures that intentionally escape are BaseExceptions such as CancelledError; preserving that behavior was part of the #4198 and #4201 fix.
In a controlled Agent.as_tool(on_stream=...) interleaving, the released code propagates CancelledError, while this patch replaces it with the producer RuntimeError. With the default failure handler, that becomes a normal tool-error result and can let the outer run continue. Since no supported scenario demonstrates why producer failure should override consumer cancellation, I do not think this change is worth merging. I am going to close this PR for now.
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
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.
Summary
run_producer_consumer()documents producer failures as primary while the consumer drains. Previously a secondary consumer exception raised during that drain replaced the producer exception.Test plan
tests/test_asyncio_tasks_primary_error.pyIssue number
N/A