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: use descriptive error messages for known errors in LLM streaming (#10207)

cthomas0a38934e5c80
diff --git a/letta/server/rest_api/redis_stream_manager.py b/letta/server/rest_api/redis_stream_manager.py
index 2eeb55f54..5f630fcb4 100644
--- a/letta/server/rest_api/redis_stream_manager.py
+++ b/letta/server/rest_api/redis_stream_manager.py
@@ -9,6 +9,7 @@ from contextlib import aclosing
from typing import Dict, List, Optional
from letta.data_sources.redis_client import AsyncRedisClient
+from letta.errors import LettaError
from letta.log import get_logger
from letta.schemas.enums import RunStatus
from letta.schemas.letta_message import LettaErrorMessage
@@ -381,7 +382,7 @@ async def create_background_stream_processor(
error_message = LettaErrorMessage(
run_id=run_id,
error_type="internal_error",
- message="An unknown error occurred with the LLM streaming request.",
+ message=str(e) if isinstance(e, LettaError) else "An unknown error occurred with the LLM streaming request.",
detail=str(e),
)
await writer.write_chunk(
diff --git a/letta/services/streaming_service.py b/letta/services/streaming_service.py
index a458be71d..1adeea2b3 100644
--- a/letta/services/streaming_service.py
+++ b/letta/services/streaming_service.py
@@ -16,6 +16,7 @@ from letta.constants import REDIS_RUN_ID_PREFIX
from letta.data_sources.redis_client import AsyncRedisClient, NoopAsyncRedisClient, get_redis_client
from letta.errors import (
ConversationBusyError,
+ LettaError,
LettaInvalidArgumentError,
LettaServiceUnavailableError,
LLMAuthenticationError,
@@ -745,7 +746,7 @@ class StreamingService:
error_message = LettaErrorMessage(
run_id=run_id,
error_type="internal_error",
- message="An unknown error occurred with the LLM streaming request.",
+ message=error_detail if isinstance(e, LettaError) else "An unknown error occurred with the LLM streaming request.",
detail=error_detail,
)
error_data = {"error": error_message.model_dump()}