From e8ec6c233f9cdc229d6a7fbfa034dc1a383bd92d Mon Sep 17 00:00:00 2001 From: Matt Zhou Date: Thu, 21 Nov 2024 09:49:10 -0800 Subject: [PATCH 1/2] Add save_agents --- letta/server/server.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/letta/server/server.py b/letta/server/server.py index e70f0e0be4..105573f886 100644 --- a/letta/server/server.py +++ b/letta/server/server.py @@ -328,6 +328,15 @@ def __init__( ) ) + def save_agents(self): + """Saves all the agents that are in the in-memory object store""" + for agent_d in self.active_agents: + try: + save_agent(agent_d["agent"], self.ms) + logger.debug(f"Saved agent {agent_d['agent_id']}") + except Exception as e: + logger.exception(f"Error occurred while trying to save agent {agent_d['agent_id']}:\n{e}") + def _get_agent(self, user_id: str, agent_id: str) -> Union[Agent, None]: """Get the agent object from the in-memory object store""" for d in self.active_agents: From 04a91563356f6c7caeb42270275ff517833d1098 Mon Sep 17 00:00:00 2001 From: Matt Zhou Date: Thu, 21 Nov 2024 09:49:27 -0800 Subject: [PATCH 2/2] Finish --- letta/server/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/letta/server/server.py b/letta/server/server.py index 105573f886..183b33f257 100644 --- a/letta/server/server.py +++ b/letta/server/server.py @@ -333,7 +333,7 @@ def save_agents(self): for agent_d in self.active_agents: try: save_agent(agent_d["agent"], self.ms) - logger.debug(f"Saved agent {agent_d['agent_id']}") + logger.info(f"Saved agent {agent_d['agent_id']}") except Exception as e: logger.exception(f"Error occurred while trying to save agent {agent_d['agent_id']}:\n{e}")