Skip to content

A programming framework for agentic AI

hook-list are updated to accept a sender argument (#1799)

Rohit Singh Rathaurdc8914731011
diff --git a/autogen/agentchat/conversable_agent.py b/autogen/agentchat/conversable_agent.py
index d23551343..6439c2099 100644
--- a/autogen/agentchat/conversable_agent.py
+++ b/autogen/agentchat/conversable_agent.py
@@ -552,7 +552,7 @@ class ConversableAgent(LLMAgent):
"""Process the message before sending it to the recipient."""
hook_list = self.hook_lists["process_message_before_send"]
for hook in hook_list:
- message = hook(message, recipient, silent)
+ message = hook(sender=self, message=message, recipient=recipient, silent=silent)
return message
def send(
diff --git a/test/agentchat/test_conversable_agent.py b/test/agentchat/test_conversable_agent.py
index df6a06a79..5247d5162 100644
--- a/test/agentchat/test_conversable_agent.py
+++ b/test/agentchat/test_conversable_agent.py
@@ -1087,9 +1087,11 @@ def test_max_turn():
def test_process_before_send():
print_mock = unittest.mock.MagicMock()
- def send_to_frontend(message, recipient, silent):
+ # Updated to include sender parameter
+ def send_to_frontend(sender, message, recipient, silent):
+ assert sender.name == "dummy_agent_1", "Sender is not the expected agent"
if not silent:
- print(f"Message sent to {recipient.name}: {message}")
+ print(f"Message sent from {sender.name} to {recipient.name}: {message}")
print_mock(message=message)
return message