diff --git a/autogen/agentchat/contrib/retrieve_user_proxy_agent.py b/autogen/agentchat/contrib/retrieve_user_proxy_agent.py index dd2ef0191270..261ab2062ef8 100644 --- a/autogen/agentchat/contrib/retrieve_user_proxy_agent.py +++ b/autogen/agentchat/contrib/retrieve_user_proxy_agent.py @@ -81,6 +81,7 @@ """ HASH_LENGTH = int(os.environ.get("HASH_LENGTH", 8)) +UPDATE_CONTEXT_IN_PROMPT = "you should reply exactly `UPDATE CONTEXT`" class RetrieveUserProxyAgent(UserProxyAgent): @@ -471,7 +472,7 @@ def _check_update_context(self, message): message = message.get("content", "") elif not isinstance(message, str): message = "" - update_context_case1 = "UPDATE CONTEXT" in message[-20:].upper() or "UPDATE CONTEXT" in message[:20].upper() + update_context_case1 = "UPDATE CONTEXT" in message.upper() and UPDATE_CONTEXT_IN_PROMPT not in message update_context_case2 = self.customized_answer_prefix and self.customized_answer_prefix not in message.upper() return update_context_case1, update_context_case2