From 9491ffa92bdb812d2938f5b1ef253f6a876b036c Mon Sep 17 00:00:00 2001 From: Igor Lins e Silva <4753812+igorls@users.noreply.github.com> Date: Tue, 7 Apr 2026 17:23:41 -0300 Subject: [PATCH] fix: add limit=10000 safety cap to all unbounded ChromaDB .get() calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevents OOM when the palace grows large. The following unbounded metadata fetches now have a safety cap: - tool_status: col.get(include=['metadatas'], limit=10000) - tool_list_wings: same - tool_list_rooms: same (including wing-filtered variant) - tool_get_taxonomy: same - Layer1.generate: col.get(include=['documents','metadatas'], limit=10000) Layer2 already had a limit parameter — no change needed. Finding: #3 (CRITICAL — unbounded data fetching causes OOM) Includes test infrastructure from PR #131. 92 tests pass. --- mempalace/mcp_server.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mempalace/mcp_server.py b/mempalace/mcp_server.py index 3861195..fd89a56 100644 --- a/mempalace/mcp_server.py +++ b/mempalace/mcp_server.py @@ -69,7 +69,7 @@ def tool_status(): wings = {} rooms = {} try: - all_meta = col.get(include=["metadatas"])["metadatas"] + all_meta = col.get(include=["metadatas"], limit=10000)["metadatas"] for m in all_meta: w = m.get("wing", "unknown") r = m.get("room", "unknown") @@ -126,7 +126,7 @@ def tool_list_wings(): return _no_palace() wings = {} try: - all_meta = col.get(include=["metadatas"])["metadatas"] + all_meta = col.get(include=["metadatas"], limit=10000)["metadatas"] for m in all_meta: w = m.get("wing", "unknown") wings[w] = wings.get(w, 0) + 1 @@ -141,7 +141,7 @@ def tool_list_rooms(wing: str = None): return _no_palace() rooms = {} try: - kwargs = {"include": ["metadatas"]} + kwargs = {"include": ["metadatas"], "limit": 10000} if wing: kwargs["where"] = {"wing": wing} all_meta = col.get(**kwargs)["metadatas"] @@ -159,7 +159,7 @@ def tool_get_taxonomy(): return _no_palace() taxonomy = {} try: - all_meta = col.get(include=["metadatas"])["metadatas"] + all_meta = col.get(include=["metadatas"], limit=10000)["metadatas"] for m in all_meta: w = m.get("wing", "unknown") r = m.get("room", "unknown")