From d16bafe428daa4827a937a215dcf343a2c8d7243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BC=9F=E9=9F=AC?= Date: Mon, 21 Oct 2024 15:52:15 +0800 Subject: [PATCH] improve fault tolerance when try to stop in ask_human action --- metagpt/roles/di/role_zero.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.py index 9baafb9b2..ca854fa60 100644 --- a/metagpt/roles/di/role_zero.py +++ b/metagpt/roles/di/role_zero.py @@ -537,7 +537,7 @@ class RoleZero(Role): command_output = await self._end() elif cmd["command_name"] == "RoleZero.ask_human": human_response = await self.ask_human(**cmd["args"]) - if human_response[len("Human response:") :].strip().lower() in ["", "stop"]: + if human_response.strip().lower().endswith(("stop", "")): human_response += "The user has asked me to stop because I have encountered a problem." self.rc.memory.add(UserMessage(content=human_response, cause_by=RunCommand)) end_output = "\nCommand end executed:"