From f1ff5cf93f693d339ab68d544ef48e47d8661fa8 Mon Sep 17 00:00:00 2001 From: yangdx Date: Mon, 25 Aug 2025 11:56:56 +0800 Subject: [PATCH] fix: initialize truncated_chunks variable in _build_query_context Prevents local variable 'truncated_chunks'referenced before assignment --- lightrag/operate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lightrag/operate.py b/lightrag/operate.py index 1e1ccbb6..68ab15a5 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -2464,6 +2464,7 @@ async def _build_query_context( # Apply token processing to merged chunks text_units_context = [] + truncated_chunks = [] if merged_chunks: # Calculate dynamic token limit for text chunks entities_str = json.dumps(entities_context, ensure_ascii=False)