Browse Source

Fix subscription decorator sharing class instances among children (#571)

tags/v0.4.0.dev0
Jack Gerrits GitHub 1 year ago
parent
commit
b8dc9fce61
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      python/packages/autogen-core/src/autogen_core/base/_base_agent.py

+ 6
- 0
python/packages/autogen-core/src/autogen_core/base/_base_agent.py View File

@@ -58,6 +58,12 @@ class BaseAgent(ABC, Agent):
_unbound_subscriptions_list: ClassVar[List[UnboundSubscription]] = []
_extra_handles_types: ClassVar[List[Tuple[Type[Any], List[MessageSerializer[Any]]]]] = []

def __init_subclass__(cls, **kwargs: Any) -> None:
super().__init_subclass__(**kwargs)
# Automatically set class_variable in each subclass so that they are not shared between subclasses
cls._extra_handles_types = []
cls._unbound_subscriptions_list = []

@classmethod
def _handles_types(cls) -> List[Tuple[Type[Any], List[MessageSerializer[Any]]]]:
return cls._extra_handles_types


Loading…
Cancel
Save