fix: use type(self) for polymorphic dispatch in CodeExecutorAgent#7437
Open
r266-tech wants to merge 2 commits intomicrosoft:mainfrom
Open
fix: use type(self) for polymorphic dispatch in CodeExecutorAgent#7437r266-tech wants to merge 2 commits intomicrosoft:mainfrom
r266-tech wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Fixes microsoft#7205 The on_messages_stream method called CodeExecutorAgent._reflect_on_code_block_results_flow via the concrete class name, breaking polymorphism for subclasses that override this method. Changed to type(self)._reflect_on_code_block_results_flow to ensure the correct subclass implementation is called, matching the pattern used in AssistantAgent (fix for microsoft#5953).
…eflection override (microsoft#7205)
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.
Fixes #7205
The
on_messages_streammethod inCodeExecutorAgentcalled_reflect_on_code_block_results_flowvia the concrete class name, breaking polymorphism for subclasses that override this method.Change
python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py:CodeExecutorAgent._reflect_on_code_block_results_flow(...)type(self)._reflect_on_code_block_results_flow(...)This matches the fix already applied to
AssistantAgentfor the same pattern (issue #5953).Test
Added
test_subclass_reflection_override_is_calledintest_code_executor_agent.py:_CustomAgentsubclass with a tracking override of_reflect_on_code_block_results_flowon_messages_streamend-to-end viaReplayChatCompletionClient