Skip to content

Commit dc89147

Browse files
hook-list are updated to accept a sender argument (#1799)
* hook-list are updated to accept a sender argument * Update the hook function Signature & add assertions for Sender
1 parent 2cf9ea4 commit dc89147

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

autogen/agentchat/conversable_agent.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ def _process_message_before_send(
552552
"""Process the message before sending it to the recipient."""
553553
hook_list = self.hook_lists["process_message_before_send"]
554554
for hook in hook_list:
555-
message = hook(message, recipient, silent)
555+
message = hook(sender=self, message=message, recipient=recipient, silent=silent)
556556
return message
557557

558558
def send(

test/agentchat/test_conversable_agent.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1087,9 +1087,11 @@ def test_max_turn():
10871087
def test_process_before_send():
10881088
print_mock = unittest.mock.MagicMock()
10891089

1090-
def send_to_frontend(message, recipient, silent):
1090+
# Updated to include sender parameter
1091+
def send_to_frontend(sender, message, recipient, silent):
1092+
assert sender.name == "dummy_agent_1", "Sender is not the expected agent"
10911093
if not silent:
1092-
print(f"Message sent to {recipient.name}: {message}")
1094+
print(f"Message sent from {sender.name} to {recipient.name}: {message}")
10931095
print_mock(message=message)
10941096
return message
10951097

0 commit comments

Comments
 (0)