Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autogen/agentchat/conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def _process_message_before_send(
"""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(
Expand Down
6 changes: 4 additions & 2 deletions test/agentchat/test_conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,9 +1077,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

Expand Down
Loading