You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add support for multi-agent communication (#4)
## Overview
This PR enhances the agent communication system by adding support for multi-agent messaging, allowing an agent to send messages to multiple recipients simultaneously. It also includes several improvements to error handling and message formatting.
### Key Changes
- Added support for sending messages to multiple agents at once via `talk_to` method
- Enhanced error handling for agent communication with better error messages
- Improved message formatting for both single and multi-agent conversations
- Added reminder in prompt template to close XML tags
- Fixed return type annotations for `ask` and `talk_to` methods
- Bumped version from 0.3.0 to 0.3.1
### Implementation Details
- Modified `Interaction` class to store receivers as a list of agents
- Updated `AgentInteractionManager` to handle multiple receivers
- Added support for "all" keyword to broadcast messages to all agents
- Enhanced error messages for invalid agent IDs
- Improved string representation of interactions for better readability
### Testing
- Added new test cases for multi-agent communication
- Updated existing tests to accommodate the new receiver list format
- Added tests for manual and automatic action execution
### Breaking Changes
None. All changes are backward compatible as single-agent communication continues to work as before.
str: A formatted string showing sender, receiver, and the interaction message.
48
48
"""
49
-
returnf"Interaction from {self.sender.name} ({self.sender.agent_id}) to {self.receiver.name} ({self.receiver.agent_id}): {self.message}"
49
+
50
+
iflen(self.receiver) ==1:
51
+
returnf"{self.sender.name} ({self.sender.agent_id}) said to {self.receiver[0].name} ({self.receiver[0].agent_id}): {self.message}"
52
+
else:
53
+
returnf"{self.sender.name} ({self.sender.agent_id}) said to {', '.join([_receiver.name+f'({_receiver.agent_id})'for_receiverinself.receiver])}: {self.message}"
50
54
51
55
def__repr__(self) ->str:
52
56
"""
@@ -56,4 +60,3 @@ def __repr__(self) -> str:
56
60
str: A formatted string showing sender, receiver, and the interaction message.
0 commit comments