Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: null check on span before log event (#2810)
cthomas3ede465b533c
diff --git a/letta/interfaces/anthropic_streaming_interface.py b/letta/interfaces/anthropic_streaming_interface.pyindex a25501d67..56def5e6a 100644--- a/letta/interfaces/anthropic_streaming_interface.py+++ b/letta/interfaces/anthropic_streaming_interface.py@@ -227,10 +227,11 @@ class AnthropicStreamingInterface:import tracebacklogger.error("Error processing stream: %s\n%s", e, traceback.format_exc())- ttft_span.add_event(- name="stop_reason",- attributes={"stop_reason": StopReasonType.error.value, "error": str(e), "stacktrace": traceback.format_exc()},- )+ if ttft_span:+ ttft_span.add_event(+ name="stop_reason",+ attributes={"stop_reason": StopReasonType.error.value, "error": str(e), "stacktrace": traceback.format_exc()},+ )yield LettaStopReason(stop_reason=StopReasonType.error)raise efinally:diff --git a/letta/interfaces/openai_streaming_interface.py b/letta/interfaces/openai_streaming_interface.pyindex bf44867a3..7c8b3d9ba 100644--- a/letta/interfaces/openai_streaming_interface.py+++ b/letta/interfaces/openai_streaming_interface.py@@ -167,10 +167,11 @@ class OpenAIStreamingInterface:import tracebacklogger.error("Error processing stream: %s\n%s", e, traceback.format_exc())- ttft_span.add_event(- name="stop_reason",- attributes={"stop_reason": StopReasonType.error.value, "error": str(e), "stacktrace": traceback.format_exc()},- )+ if ttft_span:+ ttft_span.add_event(+ name="stop_reason",+ attributes={"stop_reason": StopReasonType.error.value, "error": str(e), "stacktrace": traceback.format_exc()},+ )yield LettaStopReason(stop_reason=StopReasonType.error)raise efinally: