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: avoid calling `model_dump` on stop reason messages twice (#2811)

Sarah Wooders78e81391ba82
diff --git a/letta/interfaces/anthropic_streaming_interface.py b/letta/interfaces/anthropic_streaming_interface.py
index 3259bdd95..1bd63bbf9 100644
--- a/letta/interfaces/anthropic_streaming_interface.py
+++ b/letta/interfaces/anthropic_streaming_interface.py
@@ -387,7 +387,7 @@ class AnthropicStreamingInterface:
except Exception as e:
logger.error("Error processing stream: %s", e)
stop_reason = LettaStopReason(stop_reason=StopReasonType.error.value)
- yield f"data: {stop_reason.model_dump_json()}\n\n"
+ yield stop_reason
raise
finally:
logger.info("AnthropicStreamingInterface: Stream processing complete.")
diff --git a/letta/interfaces/openai_streaming_interface.py b/letta/interfaces/openai_streaming_interface.py
index 25a945a2c..c42115fbd 100644
--- a/letta/interfaces/openai_streaming_interface.py
+++ b/letta/interfaces/openai_streaming_interface.py
@@ -345,7 +345,7 @@ class OpenAIStreamingInterface:
except Exception as e:
logger.error("Error processing stream: %s", e)
stop_reason = LettaStopReason(stop_reason=StopReasonType.error.value)
- yield f"data: {stop_reason.model_dump_json()}\n\n"
+ yield stop_reason
raise
finally:
logger.info("OpenAIStreamingInterface: Stream processing complete.")