Skip to content

fix: mutable default arguments + bare except in code executors#7627

Open
srpatcha wants to merge 3 commits intomicrosoft:mainfrom
srpatcha:fix/bare-except-queue
Open

fix: mutable default arguments + bare except in code executors#7627
srpatcha wants to merge 3 commits intomicrosoft:mainfrom
srpatcha:fix/bare-except-queue

Conversation

@srpatcha
Copy link
Copy Markdown

@srpatcha srpatcha commented Apr 25, 2026

Why are these changes needed?

Fix two categories of bugs in the code executor implementations:

1. Replace bare except with except Exception in _queue.py

Bare except clauses catch SystemExit and KeyboardInterrupt, which should propagate.

2. Replace mutable default arguments in code executors

The functions parameter uses [] as a default value in __init__ for:

  • DockerCommandLineCodeExecutor
  • LocalCommandLineCodeExecutor
  • AzureContainerCodeExecutor

Mutable default arguments in Python are shared across all calls, which can cause unexpected behavior if the list is ever modified. Changed to None with a guard clause.

Related issue number

N/A

Checks

  • Changes follow existing code patterns
  • No breaking API changes

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.
@srpatcha srpatcha changed the title fix: replace bare except with except Exception in _queue.py fix: mutable default arguments + bare except in code executors Apr 25, 2026
@srpatcha
Copy link
Copy Markdown
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant