Skip to content

Fix potential crashes due to uninitialized variables in Gemini and ConversableAgent#7197

Open
RinZ27 wants to merge 1 commit intomicrosoft:fix_fsfrom
RinZ27:fix/uninitialized-variables-and-stability
Open

Fix potential crashes due to uninitialized variables in Gemini and ConversableAgent#7197
RinZ27 wants to merge 1 commit intomicrosoft:fix_fsfrom
RinZ27:fix/uninitialized-variables-and-stability

Conversation

@RinZ27
Copy link

@RinZ27 RinZ27 commented Feb 1, 2026

I've identified and fixed several potential UnboundLocalError crashes in the Gemini client and ConversableAgent.

Context

  1. gemini.py: The previous implementation of the create method had hardcoded checks for specific model names. If a vision model was used that didn't match the hardcoded strings, variables like ans would remain uninitialized, leading to a crash. I've added default initializations and switched to a more inclusive else block for vision models.
  2. conversable_agent.py: In execute_function (both sync and async), if a function was not found and verbose=True was set, the code would attempt to print arguments before they were defined. I've initialized arguments to None to prevent this.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature or improvement (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • I've verified the changes with py_compile.

…versableAgent

I noticed several potential crash points where variables like 'ans' and 'arguments' could be used before initialization.

- In gemini.py: Initialized 'ans' and token counters to handle edge cases where model names don't match hardcoded strings. Switched to an 'else' block for vision models to be more inclusive.
- In conversable_agent.py: Initialized 'arguments' to None in both sync and async execute_function to prevent crashes when verbose=True and a function is not found.
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.

2 participants