-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
What happened?
Describe the bug
In CodeExecutorAgent.on_messages_stream, the class method _reflect_on_code_block_results_flow is invoked via the concrete class name:
autogen/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
Lines 667 to 675 in 13e144e
| async for reflection_response in CodeExecutorAgent._reflect_on_code_block_results_flow( | |
| system_messages=system_messages, | |
| model_client=model_client, | |
| model_client_stream=model_client_stream, | |
| model_context=model_context, | |
| agent_name=agent_name, | |
| inner_messages=inner_messages, | |
| ): | |
| yield reflection_response # Last reflection_response is of type Response so it will finish the routine |
This introduces a static binding to CodeExecutorAgent and breaks polymorphism for subclasses that override _reflect_on_code_block_results_flow.
This appears to be the same pattern and root cause as a previously reported polymorphism bug:
To Reproduce
Create a child class of CodeExecutorAgent and override method _reflect_on_code_block_results_flow. When calling on_messages_stream on an agent of the custom class, it still calls the parent class's methods.
Expected behavior
The override methods should be be called.
Which packages was the bug in?
Python AgentChat (autogen-agentchat>=0.4.0)
AutoGen library version.
Python dev (main branch)
Other library version.
No response
Model used
No response
Model provider
None
Other model provider
No response
Python version
None
.NET version
None
Operating system
None