diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index 67f82910..03699e08 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -1504,6 +1504,15 @@ class LightRAG: pipeline_status["latest_message"] = log_message pipeline_status["history_messages"].append(log_message) + # Prevent memory growth: keep only latest 5000 messages when exceeding 10000 + if len(pipeline_status["history_messages"]) > 10000: + pipeline_status["history_messages"] = ( + pipeline_status["history_messages"][-5000:] + ) + logger.info( + f"Trimming pipeline history from {len(pipeline_status['history_messages'])} to 5000 messages" + ) + # Get document content from full_docs content_data = await self.full_docs.get_by_id(doc_id) if not content_data: