diff --git a/autogen/agentchat/conversable_agent.py b/autogen/agentchat/conversable_agent.py index c3394a96b..aeea27cff 100644 --- a/autogen/agentchat/conversable_agent.py +++ b/autogen/agentchat/conversable_agent.py @@ -242,7 +242,7 @@ class ConversableAgent(LLMAgent): # Registered hooks are kept in lists, indexed by hookable method, to be called in their order of registration. # New hookable methods should be added to this list as required to support new agent capabilities. - self.hook_lists = { + self.hook_lists: Dict[str, List[Callable]] = { "process_last_received_message": [], "process_all_messages_before_reply": [], "process_message_before_send": [], @@ -2724,7 +2724,7 @@ class ConversableAgent(LLMAgent): processed_messages = hook(processed_messages) return processed_messages - def process_last_received_message(self, messages): + def process_last_received_message(self, messages: List[Dict]) -> List[Dict]: """ Calls any registered capability hooks to use and potentially modify the text of the last message, as long as the last message is not a function call or exit command. @@ -2758,6 +2758,7 @@ class ConversableAgent(LLMAgent): processed_user_content = user_content for hook in hook_list: processed_user_content = hook(processed_user_content) + if processed_user_content == user_content: return messages # No hooks actually modified the user's message.