autogen/tests/test_utils/__init__.py
Jack Gerrits 5b01f69b58 Move agent creation into the runtime (#89)
* Move agent creation into the runtime

* update doc

* add test

* Remove limitation of subscriptions being same across namespaces

* constrain agent types to namespaces
2024-06-18 14:53:18 -04:00

20 lines
510 B
Python

from dataclasses import dataclass
from agnext.components import TypeRoutedAgent, message_handler
from agnext.core import CancellationToken
@dataclass
class MessageType:
...
class LoopbackAgent(TypeRoutedAgent):
def __init__(self) -> None:
super().__init__("A loop back agent.")
self.num_calls = 0
@message_handler
async def on_new_message(self, message: MessageType, cancellation_token: CancellationToken) -> MessageType:
self.num_calls += 1
return message