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: sqlalchemy instrumentation error (#2857)

cthomas273be6368dc4
diff --git a/letta/otel/sqlalchemy_instrumentation.py b/letta/otel/sqlalchemy_instrumentation.py
index ccab73a16..9305d6aa6 100644
--- a/letta/otel/sqlalchemy_instrumentation.py
+++ b/letta/otel/sqlalchemy_instrumentation.py
@@ -146,11 +146,16 @@ def _instrument_engine_events(engine: Engine) -> None:
span.end()
context._sync_instrumentation_span = None
- def handle_cursor_error(conn, cursor, statement, parameters, context, executemany):
+ def handle_cursor_error(exception_context):
"""Handle cursor execution errors."""
if not _config["enabled"]:
return
+ # Extract context from exception_context
+ context = getattr(exception_context, "execution_context", None)
+ if not context:
+ return
+
span = getattr(context, "_sync_instrumentation_span", None)
if span:
span.set_status(Status(StatusCode.ERROR, "Database operation failed"))