Inter-Agent Communication
Agent Communication
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_fromandcause_byattributes in theMessageclass).
Message Consumption:
Agents subscribe to messages based on the
cause_byattribute. This ensures each agent only receives relevant tasks or data.
Message Broadcasting:
The
Environmentobject handles broadcasting messages to agents, respecting their subscription requirements.
Message Class
class Message(BaseModel):
id: str = Field(default="", validate_default=True) # Unique message identifier
content: str
instruct_content: Optional[BaseModel] = Field(default=None, validate_default=True)
role: str = "user" # system / user / assistant
cause_by: str = Field(default="", validate_default=True)
sent_from: str = Field(default="", validate_default=True)
send_to: set[str] = Field(default={MESSAGE_ROUTE_TO_ALL}, validate_default=True)System Design
When designing an agent workflow, consider the following:
Inputs:
Define the data or messages an agent should process. This aligns with the
rc.watchattribute in the agent object.
Outputs:
Specify the messages the agent generates. These are encapsulated in the
Messageclass.
Tasks:
Determine the actions an agent performs and their transitions between states.
Example Workflow
Let’s illustrate the interaction with a complex scenario:
Agent A: Splits requirements into 10 subtasks.
Agent B: Processes each subtask.
Agent C: Compiles the processed results.
Agent D: Reviews and provides feedback to Agent B.
Steps 2–4 repeat multiple times for refinement.
Implementation
Agent A: Splits user requirements into subtasks and sends them to Agent B.
Agent B: Processes subtasks sent by Agent A or Agent D.
Agent C: Compiles outputs from Agent B.
Agent D: Reviews outputs and sends feedback to Agent B.
Environment Setup
Finally, add all agents to an Environment and initialize the workflow:
This structure ensures an efficient and modular design for managing complex multi-agent workflows in Strata AI.
Last updated