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.

fix: reduce error levels to patch the sentry logging issue (#3835)

Charles Packer722828309c6a
diff --git a/letta/services/tool_executor/tool_execution_sandbox.py b/letta/services/tool_executor/tool_execution_sandbox.py
index f487df473..bc8baf7c4 100644
--- a/letta/services/tool_executor/tool_execution_sandbox.py
+++ b/letta/services/tool_executor/tool_execution_sandbox.py
@@ -224,8 +224,10 @@ class ToolExecutionSandbox:
with open(temp_file_path, "r") as f:
code = f.read()
- logger.error(f"Executing tool {self.tool_name} has process error: {e}")
- logger.error(f"Logging out tool {self.tool_name} auto-generated code for debugging: \n\n{code}")
+ # Tool errors are expected behavior - tools can raise exceptions as part of their normal operation
+ # Only log at debug level to avoid triggering Sentry alerts for expected errors
+ logger.debug(f"Tool {self.tool_name} process error: {e}")
+ logger.debug(f"Tool {self.tool_name} auto-generated code for debugging: \n\n{code}")
func_return = get_friendly_error_msg(
function_name=self.tool_name,
exception_name=type(e).__name__,
@@ -371,8 +373,10 @@ class ToolExecutionSandbox:
},
)
elif execution.error:
- logger.error(f"Executing tool {self.tool_name} raised a {execution.error.name} with message: \n{execution.error.value}")
- logger.error(f"Traceback from e2b sandbox: \n{execution.error.traceback}")
+ # Tool errors are expected behavior - tools can raise exceptions as part of their normal operation
+ # Only log at debug level to avoid triggering Sentry alerts for expected errors
+ logger.debug(f"Tool {self.tool_name} raised a {execution.error.name}: {execution.error.value}")
+ logger.debug(f"Traceback from e2b sandbox: \n{execution.error.traceback}")
func_return = get_friendly_error_msg(
function_name=self.tool_name, exception_name=execution.error.name, exception_message=execution.error.value
)
diff --git a/letta/services/tool_sandbox/e2b_sandbox.py b/letta/services/tool_sandbox/e2b_sandbox.py
index dc1e92f57..d345ead9e 100644
--- a/letta/services/tool_sandbox/e2b_sandbox.py
+++ b/letta/services/tool_sandbox/e2b_sandbox.py
@@ -82,8 +82,10 @@ class AsyncToolSandboxE2B(AsyncToolSandboxBase):
},
)
elif execution.error:
- logger.error(f"Executing tool {self.tool_name} raised a {execution.error.name} with message: \n{execution.error.value}")
- logger.error(f"Traceback from e2b sandbox: \n{execution.error.traceback}")
+ # Tool errors are expected behavior - tools can raise exceptions as part of their normal operation
+ # Only log at debug level to avoid triggering Sentry alerts for expected errors
+ logger.debug(f"Tool {self.tool_name} raised a {execution.error.name}: {execution.error.value}")
+ logger.debug(f"Traceback from e2b sandbox: \n{execution.error.traceback}")
func_return = get_friendly_error_msg(
function_name=self.tool_name, exception_name=execution.error.name, exception_message=execution.error.value
)
diff --git a/letta/services/tool_sandbox/modal_sandbox.py b/letta/services/tool_sandbox/modal_sandbox.py
index a1ed216ad..d9236d368 100644
--- a/letta/services/tool_sandbox/modal_sandbox.py
+++ b/letta/services/tool_sandbox/modal_sandbox.py
@@ -100,10 +100,10 @@ class AsyncToolSandboxModal(AsyncToolSandboxBase):
# Process the result
if result["error"]:
- logger.error(
- f"Executing tool {self.tool_name} raised a {result['error']['name']} with message: \n{result['error']['value']}"
- )
- logger.error(f"Traceback from Modal sandbox: \n{result['error']['traceback']}")
+ # Tool errors are expected behavior - tools can raise exceptions as part of their normal operation
+ # Only log at debug level to avoid triggering Sentry alerts for expected errors
+ logger.debug(f"Tool {self.tool_name} raised a {result['error']['name']}: {result['error']['value']}")
+ logger.debug(f"Traceback from Modal sandbox: \n{result['error']['traceback']}")
func_return = get_friendly_error_msg(
function_name=self.tool_name, exception_name=result["error"]["name"], exception_message=result["error"]["value"]
)