Skip to content

Commit 2ae8e74

Browse files
committed
test: stabilize flaky retain and load batch tests
- test_retain.py: pin fact_type_override="world" on retains that later filter recall by fact_type=["world"]; the LLM was classifying facts as "experience" non-deterministically, returning 0 recall results. - test_load_large_batch.py: add disable_observations fixture so inline consolidation (SyncTaskBackend) doesn't run during load tests — the pool-under-load mock wasn't handling scope="consolidation" and was timing out under 10 concurrent retains. - test_load_large_batch.py: mark the file with xdist_group so the heavy load tests don't contend for CPU/memory with other parallel workers.
1 parent b79ab2b commit 2ae8e74

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

hindsight-api-slim/tests/test_load_large_batch.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
logger = logging.getLogger(__name__)
2727

28+
pytestmark = pytest.mark.xdist_group("load_batch_tests")
29+
2830

2931
def generate_content(char_count: int) -> str:
3032
"""Generate realistic content of approximately char_count characters."""
@@ -117,9 +119,18 @@ async def memory_with_mock_llm(self, pg0_db_url, embeddings, cross_encoder, quer
117119
except Exception:
118120
pass
119121

122+
@pytest.fixture
123+
def disable_observations(self):
124+
from hindsight_api.config import _get_raw_config
125+
config = _get_raw_config()
126+
original = config.enable_observations
127+
config.enable_observations = False
128+
yield
129+
config.enable_observations = original
130+
120131
@pytest.mark.asyncio
121132
@pytest.mark.timeout(300) # 5 minute timeout
122-
async def test_large_batch_500k_chars_20_items(self, memory_with_mock_llm, request_context):
133+
async def test_large_batch_500k_chars_20_items(self, memory_with_mock_llm, request_context, disable_observations):
123134
"""
124135
Test retaining a batch of 20 content items totaling ~500k chars.
125136
@@ -283,7 +294,7 @@ async def mock_llm_call(*args, **kwargs):
283294

284295
@pytest.mark.asyncio
285296
@pytest.mark.timeout(60)
286-
async def test_db_connection_pool_under_load(self, memory_with_mock_llm, request_context):
297+
async def test_db_connection_pool_under_load(self, memory_with_mock_llm, request_context, disable_observations):
287298
"""
288299
Test that DB connection pool handles concurrent operations.
289300

hindsight-api-slim/tests/test_retain.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ async def test_mentioned_at_vs_occurred(memory, request_context):
378378
content="Alice graduated from MIT in March 2020.",
379379
context="education history",
380380
event_date=conversation_date, # When this conversation happened
381+
fact_type_override="world",
381382
request_context=request_context,
382383
)
383384

@@ -1149,6 +1150,7 @@ async def test_chunk_fact_mapping(memory, request_context):
11491150
content=content,
11501151
context="technical documentation",
11511152
document_id=document_id,
1153+
fact_type_override="world",
11521154
request_context=request_context,
11531155
)
11541156

0 commit comments

Comments
 (0)