From 5ecb913a3f5530c892155e54bab45f6a6abc4bdd Mon Sep 17 00:00:00 2001 From: cpacker Date: Sun, 22 Dec 2024 18:44:25 -0800 Subject: [PATCH] fix: patch bad runtime error related to memory access (SandboxReturn.agent_stateis Optional, so not guaranteed to exist) --- letta/agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/letta/agent.py b/letta/agent.py index 371595a6e6..1096668e37 100644 --- a/letta/agent.py +++ b/letta/agent.py @@ -237,8 +237,8 @@ def execute_tool_and_persist_state(self, function_name: str, function_args: dict ) function_response, updated_agent_state = sandbox_run_result.func_return, sandbox_run_result.agent_state assert orig_memory_str == self.agent_state.memory.compile(), "Memory should not be modified in a sandbox tool" - - self.update_memory_if_change(updated_agent_state.memory) + if updated_agent_state is not None: + self.update_memory_if_change(updated_agent_state.memory) except Exception as e: # Need to catch error here, or else trunction wont happen # TODO: modify to function execution error