fix: mutable default arguments + bare except in code executors#7627
Open
srpatcha wants to merge 3 commits intomicrosoft:mainfrom
Open
fix: mutable default arguments + bare except in code executors#7627srpatcha wants to merge 3 commits intomicrosoft:mainfrom
srpatcha wants to merge 3 commits intomicrosoft:mainfrom
Conversation
Bare except clauses catch SystemExit, KeyboardInterrupt and GeneratorExit which can mask critical errors and prevent clean shutdown. Using except Exception follows Python best practices.
Replace functions: Sequence[...] = [] with functions: Sequence[...] | None = None in __init__ parameters for: - DockerCommandLineCodeExecutor - LocalCommandLineCodeExecutor - AzureContainerCodeExecutor Mutable default arguments in Python are shared across all calls, which can cause unexpected behavior if the list is modified. Added None guard at the top of __init__ to create a fresh list.
Author
|
@microsoft-github-policy-service agree |
…aker - Implement RetryAgent class wrapping any agent - Add configurable retry logic with max retries and exception filtering - Support exponential backoff with jitter - Implement circuit breaker pattern for failure isolation - Add fallback agent support - Include timeout handling via asyncio.wait_for - Track retry metrics (attempts, delays, errors) - Add standalone retry_with_backoff utility function - Add comprehensive pytest tests Bug-fix: Add proper timeout handling for long-running agent calls using asyncio.wait_for Signed-off-by: Srikanth Patchava <spatchava@meta.com>
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.
Why are these changes needed?
Fix two categories of bugs in the code executor implementations:
1. Replace bare except with
except Exceptionin_queue.pyBare except clauses catch
SystemExitandKeyboardInterrupt, which should propagate.2. Replace mutable default arguments in code executors
The
functionsparameter uses[]as a default value in__init__for:DockerCommandLineCodeExecutorLocalCommandLineCodeExecutorAzureContainerCodeExecutorMutable default arguments in Python are shared across all calls, which can cause unexpected behavior if the list is ever modified. Changed to
Nonewith a guard clause.Related issue number
N/A
Checks