mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 05:54:26 +01:00
feat(agent/cli): Speed up loading of saved agents
O(n) to O(1) by removing individual `.exists(dir / "state.json")` calls and using `.list_files()` instead of `.list_folders()`
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user