From 8686f4fdd6985aa1b613436005b26bd74d1169a9 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Thu, 26 Feb 2026 12:50:47 -0500 Subject: [PATCH] fix: align default limits and parameter names to spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - get_recent_memories: limit default 10 → 5 - get_memories_by_topics: limit default 10 → 5 - prune_excess_memories: rename 'cap' → 'max_memories' Co-Authored-By: Claude Opus 4.6 --- utils/database.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/database.py b/utils/database.py index 42b237c..fb64fb5 100644 --- a/utils/database.py +++ b/utils/database.py @@ -548,7 +548,7 @@ class Database: finally: conn.close() - async def get_recent_memories(self, user_id: int, limit: int = 10) -> list[dict]: + async def get_recent_memories(self, user_id: int, limit: int = 5) -> list[dict]: """Get the N most recent non-expired memories for a user.""" if not self._available: return [] @@ -583,7 +583,7 @@ class Database: finally: conn.close() - async def get_memories_by_topics(self, user_id: int, topic_keywords: list[str], limit: int = 10) -> list[dict]: + async def get_memories_by_topics(self, user_id: int, topic_keywords: list[str], limit: int = 5) -> list[dict]: """Get non-expired memories matching any of the given topic keywords via LIKE.""" if not self._available: return [] @@ -655,18 +655,18 @@ class Database: finally: conn.close() - async def prune_excess_memories(self, user_id: int, cap: int = 50) -> int: + async def prune_excess_memories(self, user_id: int, max_memories: int = 50) -> int: """Delete excess memories for a user beyond the cap, keeping high importance and newest first. Returns count deleted.""" if not self._available: return 0 try: - return await asyncio.to_thread(self._prune_excess_memories_sync, user_id, cap) + return await asyncio.to_thread(self._prune_excess_memories_sync, user_id, max_memories) except Exception: logger.exception("Failed to prune excess memories") return 0 - def _prune_excess_memories_sync(self, user_id, cap) -> int: + def _prune_excess_memories_sync(self, user_id, max_memories) -> int: conn = self._connect() try: cursor = conn.cursor() @@ -689,7 +689,7 @@ class Database: ) ranked WHERE rn > ? )""", - user_id, cap, + user_id, max_memories, ) count = cursor.rowcount cursor.close()