From 1881f4f7cd8cb8a05817b2732eeb0ae3c958b71f Mon Sep 17 00:00:00 2001 From: Krzysztof Czerwinski <34861343+kcze@users.noreply.github.com> Date: Wed, 28 Feb 2024 19:18:57 +0100 Subject: [PATCH] feat(agent): Gracefully handle failure to load non-existing agent (#6938) --- autogpts/autogpt/autogpt/app/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/autogpts/autogpt/autogpt/app/main.py b/autogpts/autogpt/autogpt/app/main.py index 20f1d98724ff..47908a3addb6 100644 --- a/autogpts/autogpt/autogpt/app/main.py +++ b/autogpts/autogpt/autogpt/app/main.py @@ -164,7 +164,12 @@ async def run_auto_gpt( if re.match(r"^\d+$", load_existing_agent): load_existing_agent = existing_agents[int(load_existing_agent) - 1] elif load_existing_agent and load_existing_agent not in existing_agents: - raise ValueError(f"Unknown agent '{load_existing_agent}'") + logger.info( + f"Unknown agent '{load_existing_agent}', " + f"creating a new one instead.", + extra={"color": Fore.YELLOW}, + ) + load_existing_agent = "" # Either load existing or set up new agent state agent = None