Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

feat: misc server updates (#1275)

Charles Packeraec971c1b23f
diff --git a/memgpt/server/server.py b/memgpt/server/server.py
index 9084b3143..bf38d6880 100644
--- a/memgpt/server/server.py
+++ b/memgpt/server/server.py
@@ -818,7 +818,10 @@ class SyncServer(LockingServer):
return agent_config
# TODO make return type pydantic
- def list_agents(self, user_id: uuid.UUID) -> dict:
+ def list_agents(
+ self,
+ user_id: uuid.UUID,
+ ) -> dict:
"""List all available agents to a user"""
if self.ms.get_user(user_id=user_id) is None:
raise ValueError(f"User user_id={user_id} does not exist")
@@ -873,6 +876,9 @@ class SyncServer(LockingServer):
sources = [self.ms.get_source(source_id=s_id) for s_id in sources_ids]
return_dict["sources"] = [vars(s) for s in sources]
+ # Sort agents by "last_run" in descending order, most recent first
+ agents_states_dicts.sort(key=lambda x: x["last_run"], reverse=True)
+
logger.info(f"Retrieved {len(agents_states)} agents for user {user_id}:\n{[vars(s) for s in agents_states]}")
return {
"num_agents": len(agents_states),