feat: able to send to multiple receivers #42

Merged
k.marinus merged 4 commits from feat/multiple-receivers into dev 2026-01-15 09:26:14 +00:00
2 changed files with 18 additions and 11 deletions
Showing only changes of commit c0b8fb8612 - Show all commits

View File

@@ -130,7 +130,12 @@ class BaseAgent(ABC):
:param message: The message to send. :param message: The message to send.
""" """
target = AgentDirectory.get(message.to) to = message.to
receivers = [to] if isinstance(to, str) else to
for receiver in receivers:
target = AgentDirectory.get(receiver)
if target: if target:
await target.inbox.put(message) await target.inbox.put(message)
self.logger.debug(f"Sent message {message.body} to {message.to} via regular inbox.") self.logger.debug(f"Sent message {message.body} to {message.to} via regular inbox.")

View File

@@ -1,3 +1,5 @@
from collections.abc import Iterable
from pydantic import BaseModel from pydantic import BaseModel
@@ -11,7 +13,7 @@ class InternalMessage(BaseModel):
:ivar thread: An optional thread identifier/topic to categorize the message (e.g., 'beliefs'). :ivar thread: An optional thread identifier/topic to categorize the message (e.g., 'beliefs').
""" """
to: str to: str | Iterable[str]
sender: str sender: str
body: str body: str
thread: str | None = None thread: str | None = None