From 0faa61a4986b3e64771f7573c9b4bd79f4c220fe Mon Sep 17 00:00:00 2001 From: Jack Arturo Date: Sun, 12 Apr 2026 17:44:06 -0700 Subject: [PATCH 1/2] feat(graph): support unbounded visualizer snapshots Allow the graph visualizer to request the full snapshot and expose the archive threshold in graph metadata so the viewer can align its filtering with server-side state. Made-with: Cursor --- automem/api/graph.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/automem/api/graph.py b/automem/api/graph.py index a5cbaf40..7132f62a 100644 --- a/automem/api/graph.py +++ b/automem/api/graph.py @@ -14,7 +14,13 @@ from flask import Blueprint, abort, jsonify, request -from automem.config import MEMORY_TYPES, PUBLIC_RELATIONS, RELATION_COLORS, normalize_relation_type +from automem.config import ( + CONSOLIDATION_ARCHIVE_THRESHOLD, + MEMORY_TYPES, + PUBLIC_RELATIONS, + RELATION_COLORS, + normalize_relation_type, +) from automem.utils.graph import _serialize_node logger = logging.getLogger("automem.api.graph") @@ -55,7 +61,8 @@ def snapshot() -> Any: """ query_start = time.perf_counter() - limit = min(int(request.args.get("limit", 500)), 2000) + limit_raw = int(request.args.get("limit", 500)) + limit = 0 if limit_raw == 0 else min(limit_raw, 50000) min_importance = float(request.args.get("min_importance", 0.0)) types_filter = ( request.args.get("types", "").split(",") if request.args.get("types") else None @@ -68,7 +75,7 @@ def snapshot() -> Any: # Build Cypher query for nodes where_clauses = ["m.importance >= $min_importance"] - params: Dict[str, Any] = {"min_importance": min_importance, "limit": limit} + params: Dict[str, Any] = {"min_importance": min_importance} if types_filter and types_filter[0]: where_clauses.append("m.type IN $types") @@ -80,13 +87,18 @@ def snapshot() -> Any: where_clause = " AND ".join(where_clauses) - # Fetch nodes + # Fetch nodes (limit=0 means return all) + limit_clause = "" + if limit > 0: + limit_clause = "LIMIT $limit" + params["limit"] = limit + node_query = f""" MATCH (m:Memory) WHERE {where_clause} RETURN m ORDER BY m.importance DESC, m.timestamp DESC - LIMIT $limit + {limit_clause} """ try: @@ -181,6 +193,7 @@ def snapshot() -> Any: "type_colors": TYPE_COLORS, "relation_colors": RELATION_COLORS, "query_time_ms": round(elapsed * 1000, 2), + "archive_threshold": CONSOLIDATION_ARCHIVE_THRESHOLD, }, } ) @@ -430,6 +443,7 @@ def stats() -> Any: "type_colors": TYPE_COLORS, "relation_colors": RELATION_COLORS, "query_time_ms": round(elapsed * 1000, 2), + "archive_threshold": CONSOLIDATION_ARCHIVE_THRESHOLD, }, } ) From 031ee07b0a516a815e9a76f51fad68b0f0796078 Mon Sep 17 00:00:00 2001 From: Jack Arturo Date: Sat, 6 Jun 2026 19:27:33 +0200 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- automem/api/graph.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/automem/api/graph.py b/automem/api/graph.py index 7132f62a..50e44f1f 100644 --- a/automem/api/graph.py +++ b/automem/api/graph.py @@ -61,7 +61,12 @@ def snapshot() -> Any: """ query_start = time.perf_counter() - limit_raw = int(request.args.get("limit", 500)) + try: + limit_raw = int(request.args.get("limit", 500)) + except (TypeError, ValueError): + limit_raw = 500 + if limit_raw < 0: + abort(400, description="limit must be >= 0") limit = 0 if limit_raw == 0 else min(limit_raw, 50000) min_importance = float(request.args.get("min_importance", 0.0)) types_filter = (