Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix(core): change the backend mid-stream error packing to match what the FE expects [PRO-1107] (#4340)
Charles Packer7d388bff3213
diff --git a/letta/server/rest_api/redis_stream_manager.py b/letta/server/rest_api/redis_stream_manager.pyindex e3b31dd77..951b511a9 100644--- a/letta/server/rest_api/redis_stream_manager.py+++ b/letta/server/rest_api/redis_stream_manager.py@@ -225,7 +225,8 @@ async def create_background_stream_processor(except Exception as e:logger.error(f"Error processing stream for run {run_id}: {e}")# Write error chunk- error_chunk = {"error": {"message": str(e)}}+ # error_chunk = {"error": {"message": str(e)}}+ error_chunk = {"error": str(e), "code": "INTERNAL_SERVER_ERROR"}await writer.write_chunk(run_id=run_id, data=f"event: error\ndata: {json.dumps(error_chunk)}\n\n", is_complete=True)finally:if should_stop_writer:diff --git a/letta/server/rest_api/streaming_response.py b/letta/server/rest_api/streaming_response.pyindex 642b59a2d..9d1b01c9e 100644--- a/letta/server/rest_api/streaming_response.py+++ b/letta/server/rest_api/streaming_response.py@@ -298,7 +298,8 @@ class StreamingResponseWithStatusCode(StreamingResponse):except Exception as exc:logger.exception(f"Unhandled Streaming Error: {str(exc)}")more_body = False- error_resp = {"error": {"message": str(exc)}}+ # error_resp = {"error": {"message": str(exc)}}+ error_resp = {"error": str(exc), "code": "INTERNAL_SERVER_ERROR"}error_event = f"event: error\ndata: {json.dumps(error_resp)}\n\n".encode(self.charset)logger.debug("response_started:", self.response_started)if not self.response_started: