A Simple and Universal Swarm Intelligence Engine, Predicting Anything. 简洁通用的群体智能引擎,预测万物
Python agent-memoryfinancial-forecastingfuture-predictionknowledge-graphllmsmulti-agent-simulationpublic-opinion-analysispython3social-predictionswarm-intelligence
fix: add max_items limit to fetch_all_edges to prevent unbounded memory growth (#513)
harshitanande58d4f1cc5f8
diff --git a/backend/app/utils/zep_paging.py b/backend/app/utils/zep_paging.pyindex 943cd1ae..8e40226c 100644--- a/backend/app/utils/zep_paging.py+++ b/backend/app/utils/zep_paging.py@@ -19,6 +19,7 @@ logger = get_logger('mirofish.zep_paging')_DEFAULT_PAGE_SIZE = 100_MAX_NODES = 2000+_MAX_EDGES = 5000_DEFAULT_MAX_RETRIES = 3_DEFAULT_RETRY_DELAY = 2.0 # seconds, doubles each retry@@ -106,10 +107,11 @@ def fetch_all_edges(client: Zep,graph_id: str,page_size: int = _DEFAULT_PAGE_SIZE,+ max_items: int = _MAX_EDGES,max_retries: int = _DEFAULT_MAX_RETRIES,retry_delay: float = _DEFAULT_RETRY_DELAY,) -> list[Any]:- """分页获取图谱所有边,返回完整列表。每页请求自带重试。"""+ """分页获取图谱所有边,最多返回 max_items 条(默认 5000)。每页请求自带重试。"""all_edges: list[Any] = []cursor: str | None = Nonepage_num = 0@@ -132,6 +134,10 @@ def fetch_all_edges(breakall_edges.extend(batch)+ if len(all_edges) >= max_items:+ all_edges = all_edges[:max_items]+ logger.warning(f"Edge count reached limit ({max_items}), stopping pagination for graph {graph_id}")+ breakif len(batch) < page_size:break