Skip to content

fix: use type(self) for polymorphic dispatch in CodeExecutorAgent#7437

Open
r266-tech wants to merge 1 commit intomicrosoft:mainfrom
r266-tech:fix/polymorphism-code-executor-agent
Open

fix: use type(self) for polymorphic dispatch in CodeExecutorAgent#7437
r266-tech wants to merge 1 commit intomicrosoft:mainfrom
r266-tech:fix/polymorphism-code-executor-agent

Conversation

@r266-tech
Copy link
Copy Markdown

Fixes #7205

The on_messages_stream method in CodeExecutorAgent called _reflect_on_code_block_results_flow via the concrete class name CodeExecutorAgent._reflect_on_code_block_results_flow(...), breaking polymorphism for subclasses that override this method.

Change

Changed line 667 from:

CodeExecutorAgent._reflect_on_code_block_results_flow(...)

to:

type(self)._reflect_on_code_block_results_flow(...)

This ensures the correct subclass implementation is called, matching the pattern used in the fix for the similar issue #5953 in AssistantAgent.

Impact

  • 1 line changed in python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
  • Subclasses of CodeExecutorAgent that override _reflect_on_code_block_results_flow will now have their override called correctly
  • No behavior change for users who don't subclass CodeExecutorAgent

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).
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.

Polymorphism issue: CodeExecutorAgent calls classmethod via concrete class in on_messages_stream

1 participant