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: handle llm error during streaming [LET-6280] (#6341)

Ari Webb30dab0abb9ce
diff --git a/letta/adapters/simple_llm_stream_adapter.py b/letta/adapters/simple_llm_stream_adapter.py
index bb8b98f93..1b575147d 100644
--- a/letta/adapters/simple_llm_stream_adapter.py
+++ b/letta/adapters/simple_llm_stream_adapter.py
@@ -117,9 +117,13 @@ class SimpleLLMStreamAdapter(LettaLLMStreamAdapter):
raise self.llm_client.handle_llm_error(e)
# Process the stream and yield chunks immediately for TTFT
- async for chunk in self.interface.process(stream): # TODO: add ttft span
- # Yield each chunk immediately as it arrives
- yield chunk
+ try:
+ async for chunk in self.interface.process(stream): # TODO: add ttft span
+ # Yield each chunk immediately as it arrives
+ yield chunk
+ except Exception as e:
+ # Map provider-specific errors during streaming to common LLMError types
+ raise self.llm_client.handle_llm_error(e)
# After streaming completes, extract the accumulated data
self.llm_request_finish_timestamp_ns = get_utc_timestamp_ns()