Bug
The fetch_all_nodes function has a max_items parameter (default 2000) to prevent fetching too many items, but fetch_all_edges was missing this safeguard. This could cause memory issues with graphs that have a large number of edges.
Proposed Fix
Add _MAX_EDGES = 5000 as the default limit for edges, matching the pattern already established for nodes.
File
backend/app/utils/zep_paging.py
Code Change
# Add constant
_MAX_EDGES = 5000
# Update function signature
def fetch_all_edges(
client: Zep,
graph_id: str,
page_size: int = _DEFAULT_PAGE_SIZE,
max_items: int = _MAX_EDGES, # Add this parameter
...
):
# Add check in the loop
if len(all_edges) >= max_items:
all_edges = all_edges[:max_items]
logger.warning(f"Edge count reached limit ({max_items}), stopping pagination...")
break
Bug
The
fetch_all_nodesfunction has amax_itemsparameter (default 2000) to prevent fetching too many items, butfetch_all_edgeswas missing this safeguard. This could cause memory issues with graphs that have a large number of edges.Proposed Fix
Add
_MAX_EDGES = 5000as the default limit for edges, matching the pattern already established for nodes.File
backend/app/utils/zep_paging.pyCode Change