From 310f8eef69b31096c163d044ab41341c915973db Mon Sep 17 00:00:00 2001 From: NazimRiyadh Date: Sun, 14 Dec 2025 16:23:59 +0600 Subject: [PATCH] Fix: KeyError 'history_messages' in apipeline_process_enqueue_documents --- lightrag/lightrag.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index 8a638759..5f542fd2 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -1650,8 +1650,11 @@ class LightRAG: "latest_message": "", } ) - # Cleaning history_messages without breaking it as a shared list object - del pipeline_status["history_messages"][:] + #Fix: Check if key exists before deleting to prevent KeyError + if "history_messages" in pipeline_status: + del pipeline_status["history_messages"][:] + else: + pipeline_status["history_messages"] = [] else: # Another process is busy, just set request flag and return pipeline_status["request_pending"] = True