aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Krzysztof Czerwinski <34861343+kcze@users.noreply.github.com> 2024-03-22 14:55:49 +0100
committerGravatar GitHub <noreply@github.com> 2024-03-22 14:55:49 +0100
commit262771a69c787814222e23d856f4438333256245 (patch)
tree443f3dfa948a3be255a6e8b1555c096b374cb126
parentsecurity(agent): Replace unsafe `pyyaml` loader with `SafeLoader` (#7035) (diff)
downloadAuto-GPT-262771a69c787814222e23d856f4438333256245.tar.gz
Auto-GPT-262771a69c787814222e23d856f4438333256245.tar.bz2
Auto-GPT-262771a69c787814222e23d856f4438333256245.zip
fix(agent): Fix check when loading an existing agent (#7026)
Now the check also ensures the chosen agent number is within proper range
-rw-r--r--autogpts/autogpt/autogpt/app/main.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/autogpts/autogpt/autogpt/app/main.py b/autogpts/autogpt/autogpt/app/main.py
index 30ab1120f..04df5e1a6 100644
--- a/autogpts/autogpt/autogpt/app/main.py
+++ b/autogpts/autogpt/autogpt/app/main.py
@@ -185,9 +185,12 @@ async def run_auto_gpt(
"Enter the number or name of the agent to run,"
" or hit enter to create a new one:",
)
- if re.match(r"^\d+$", load_existing_agent):
+ if re.match(r"^\d+$", load_existing_agent.strip()) and 0 < int(
+ load_existing_agent
+ ) <= len(existing_agents):
load_existing_agent = existing_agents[int(load_existing_agent) - 1]
- elif load_existing_agent and load_existing_agent not in existing_agents:
+
+ if load_existing_agent not in existing_agents:
logger.info(
f"Unknown agent '{load_existing_agent}', "
f"creating a new one instead.",