Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: log stream cancellation to sentry (#3759)
cthomas7d33254f5f3f
diff --git a/letta/interfaces/anthropic_streaming_interface.py b/letta/interfaces/anthropic_streaming_interface.pyindex 9e1328fae..3022a11c5 100644--- a/letta/interfaces/anthropic_streaming_interface.py+++ b/letta/interfaces/anthropic_streaming_interface.py@@ -389,13 +389,24 @@ class AnthropicStreamingInterface:self.anthropic_mode = Noneexcept asyncio.CancelledError as e:- logger.info("Cancelled stream %s", e)- yield LettaStopReason(stop_reason=StopReasonType.cancelled)- raise+ import traceback++ logger.error("Cancelled stream %s: %s", e, traceback.format_exc())+ ttft_span.add_event(+ name="stop_reason",+ attributes={"stop_reason": StopReasonType.cancelled.value, "error": str(e), "stacktrace": traceback.format_exc()},+ )+ raise eexcept Exception as e:- logger.error("Error processing stream: %s", e)+ import traceback++ logger.error("Error processing stream: %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()},+ )yield LettaStopReason(stop_reason=StopReasonType.error)- raise+ raise efinally:logger.info("AnthropicStreamingInterface: Stream processing complete.")diff --git a/letta/interfaces/openai_streaming_interface.py b/letta/interfaces/openai_streaming_interface.pyindex aee3584d3..710c3ba0d 100644--- a/letta/interfaces/openai_streaming_interface.py+++ b/letta/interfaces/openai_streaming_interface.py@@ -389,12 +389,23 @@ class OpenAIStreamingInterface:yield tool_call_msgself.function_id_buffer = Noneexcept asyncio.CancelledError as e:- logger.info("Cancelled stream %s", e)- yield LettaStopReason(stop_reason=StopReasonType.cancelled)- raise+ import traceback++ logger.error("Cancelled stream %s: %s", e, traceback.format_exc())+ ttft_span.add_event(+ name="stop_reason",+ attributes={"stop_reason": StopReasonType.cancelled.value, "error": str(e), "stacktrace": traceback.format_exc()},+ )+ raise eexcept Exception as e:- logger.error("Error processing stream: %s", e)+ import traceback++ logger.error("Error processing stream: %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()},+ )yield LettaStopReason(stop_reason=StopReasonType.error)- raise+ raise efinally:logger.info("OpenAIStreamingInterface: Stream processing complete.")