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.

fix(tests): skip memory tests when hnswlib not available

Claude Code Botb6b8eed3bd86
diff --git a/tests/test_memory/test_core_operations.py b/tests/test_memory/test_core_operations.py
index 9eff5dbe2..e6979bdb3 100644
--- a/tests/test_memory/test_core_operations.py
+++ b/tests/test_memory/test_core_operations.py
@@ -31,6 +31,16 @@ from headroom.memory.core import HierarchicalMemory
from headroom.memory.models import Memory, ScopeLevel
from headroom.memory.ports import MemoryFilter
+# Check if hnswlib is available (HierarchicalMemory requires it)
+try:
+ from headroom.memory.adapters.hnsw import _check_hnswlib_available
+
+ HNSW_AVAILABLE = _check_hnswlib_available()
+except ImportError:
+ HNSW_AVAILABLE = False
+
+pytestmark = pytest.mark.skipif(not HNSW_AVAILABLE, reason="hnswlib not available")
+
def network_timeout_handler(func):
"""Decorator to skip tests on network timeouts (flaky CI)."""
diff --git a/tests/test_memory/test_easy.py b/tests/test_memory/test_easy.py
index ec6051479..1f775103c 100644
--- a/tests/test_memory/test_easy.py
+++ b/tests/test_memory/test_easy.py
@@ -26,6 +26,16 @@ import pytest
from headroom.memory.easy import Memory, MemoryResult
+# Check if hnswlib is available (local backend requires it)
+try:
+ from headroom.memory.adapters.hnsw import _check_hnswlib_available
+
+ HNSW_AVAILABLE = _check_hnswlib_available()
+except ImportError:
+ HNSW_AVAILABLE = False
+
+pytestmark = pytest.mark.skipif(not HNSW_AVAILABLE, reason="hnswlib not available")
+
def network_timeout_handler(func):
"""Decorator to skip tests on network timeouts (flaky CI)."""
diff --git a/tests/test_memory/test_factory.py b/tests/test_memory/test_factory.py
index 2a3fc4fa1..33d403c34 100644
--- a/tests/test_memory/test_factory.py
+++ b/tests/test_memory/test_factory.py
@@ -26,6 +26,16 @@ from headroom.memory.factory import (
create_memory_system,
)
+# Check if hnswlib is available (most factory tests require it)
+try:
+ from headroom.memory.adapters.hnsw import _check_hnswlib_available
+
+ HNSW_AVAILABLE = _check_hnswlib_available()
+except ImportError:
+ HNSW_AVAILABLE = False
+
+pytestmark = pytest.mark.skipif(not HNSW_AVAILABLE, reason="hnswlib not available")
+
# =============================================================================
# Test MemoryConfig
# =============================================================================