Skip to content

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

refactor(memory): deprecate unused SQLiteMemoryStore.count_sync (#4113)

Tejas Chopra235043d39bfa
diff --git a/headroom/memory/adapters/sqlite.py b/headroom/memory/adapters/sqlite.py
index 4a5b339ae..63b795309 100644
--- a/headroom/memory/adapters/sqlite.py
+++ b/headroom/memory/adapters/sqlite.py
@@ -13,6 +13,7 @@ import contextlib
import json
import re
import sqlite3
+import warnings
from datetime import datetime, timezone
from pathlib import Path
from typing import TYPE_CHECKING, Any
@@ -878,9 +879,19 @@ class SQLiteMemoryStore:
def count_sync(self) -> int:
"""Synchronous count of all memories (for diagnostics).
+ .. deprecated::
+ Nothing in Headroom calls this. Use the async
+ ``count(MemoryFilter(include_superseded=True))`` instead.
+
Returns:
Total number of memories in the store.
"""
+ warnings.warn(
+ "SQLiteMemoryStore.count_sync is deprecated and will be removed in a future "
+ "release; use the async count(MemoryFilter(include_superseded=True)) instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
with self._get_conn() as conn:
cursor = conn.execute("SELECT COUNT(*) FROM memories")
result = cursor.fetchone()[0]
diff --git a/tests/test_memory/test_adapter_deprecations.py b/tests/test_memory/test_adapter_deprecations.py
new file mode 100644
index 000000000..97ca3789d
--- /dev/null
+++ b/tests/test_memory/test_adapter_deprecations.py
@@ -0,0 +1,15 @@
+"""Deprecated memory adapter methods still work and warn."""
+
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+
+from headroom.memory.adapters.sqlite import SQLiteMemoryStore
+
+
+def test_count_sync_warns_deprecated(tmp_path: Path) -> None:
+ store = SQLiteMemoryStore(str(tmp_path / "mem.db"))
+ with pytest.warns(DeprecationWarning, match="SQLiteMemoryStore.count_sync is deprecated"):
+ assert store.count_sync() == 0