diff options
| author | Krzysztof Czerwinski <34861343+kcze@users.noreply.github.com> | 2024-03-22 14:55:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-22 14:55:49 +0100 |
| commit | 262771a69c787814222e23d856f4438333256245 (patch) | |
| tree | 443f3dfa948a3be255a6e8b1555c096b374cb126 | |
| parent | a1ffe15142218705e4bf867fcddf701ae986f9c5 (diff) | |
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.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/autogpts/autogpt/autogpt/app/main.py b/autogpts/autogpt/autogpt/app/main.py index 30ab1120..04df5e1a 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.", |
