From 9330ccb14efee70974f73c6f250eb27aca4fb0bf Mon Sep 17 00:00:00 2001 From: yangdx Date: Sat, 20 Sep 2025 13:33:19 +0800 Subject: [PATCH] Fix graph truncation logging to correctly identify truncation cause --- lightrag/kg/networkx_impl.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lightrag/kg/networkx_impl.py b/lightrag/kg/networkx_impl.py index 0407422a..1f716ba0 100644 --- a/lightrag/kg/networkx_impl.py +++ b/lightrag/kg/networkx_impl.py @@ -403,15 +403,13 @@ class NetworkXStorage(BaseGraphStorage): # Check if graph is truncated - either due to max_nodes limit or depth limit if (queue and len(bfs_nodes) >= max_nodes) or has_unexplored_neighbors: result.is_truncated = True - if has_unexplored_neighbors and not ( - queue and len(bfs_nodes) >= max_nodes - ): + if len(bfs_nodes) >= max_nodes: logger.info( - f"[{self.workspace}] Graph truncated: reached max_depth {max_depth}, unexplored neighbors exist" + f"[{self.workspace}] Graph truncated: max_nodes limit {max_nodes} reached" ) else: logger.info( - f"[{self.workspace}] Graph truncated: breadth-first search limited to {max_nodes} nodes" + f"[{self.workspace}] Graph truncated: only {len(bfs_nodes)} nodes found within max_depth {max_depth}" ) # Create subgraph with BFS discovered nodes