Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(agent/cli): Speed up loading of saved agents

Reinier van der Leer126aacb2e304
diff --git a/autogpts/autogpt/autogpt/agent_manager/agent_manager.py b/autogpts/autogpt/autogpt/agent_manager/agent_manager.py
index fd3becf840..011f868b05 100644
--- a/autogpts/autogpt/autogpt/agent_manager/agent_manager.py
+++ b/autogpts/autogpt/autogpt/agent_manager/agent_manager.py
@@ -20,9 +20,9 @@ class AgentManager:
def list_agents(self) -> list[str]:
"""Return all agent directories within storage."""
agent_dirs: list[str] = []
- for dir in self.file_manager.list_folders():
- if self.file_manager.exists(dir / "state.json"):
- agent_dirs.append(dir.name)
+ for file_path in self.file_manager.list_files():
+ if len(file_path.parts) == 2 and file_path.name == "state.json":
+ agent_dirs.append(file_path.parent.name)
return agent_dirs
def get_agent_dir(self, agent_id: str) -> Path: