In Strata AI, agents interact by exchanging messages, ensuring an efficient flow of tasks and data between components. This communication is managed through the Message class and the publish_message capability provided by the Environment.
Key Concepts
Message Sending:
When an agent sends a message, it specifies the source information (e.g., sent_from and cause_by attributes in the Message class).
Message Consumption:
Agents subscribe to messages based on the cause_by attribute. This ensures each agent only receives relevant tasks or data.
Message Broadcasting:
The Environment object handles broadcasting messages to agents, respecting their subscription requirements.
Agent D: Reviews outputs and sends feedback to Agent B.
class AgentD(Role):
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
self.set_actions([AgentDAction])
self._watch({AgentCAction})
class AgentDAction(Action):
async def run(self, with_messages: List[Message] = None, **kwargs) -> Message:
# Review and provide feedback
...
Environment Setup
Finally, add all agents to an Environment and initialize the workflow:
context = Context() # Load configuration
env = Environment(context=context)
env.add_roles([AgentA(), AgentB(), AgentC(), AgentD()])
env.publish_message(Message(content='New user requirements', send_to=AgentA))
while not env.is_idle: # Runs until all messages are processed
await env.run()
This structure ensures an efficient and modular design for managing complex multi-agent workflows in Strata AI.