Scoped Agent Memory: Why a Post-Filtered Top-k Returns One or Two Rows and Ships the Rest to the Model (2026)

A team keeps every user’s or tenant’s memories in one vector collection and enforces isolation in application code. The search returns the nearest neighbours, then a list comprehension keeps the rows that belong to the caller: rows = store.search(query, k=5) rows = [r for r in rows if r["tenant_id"] == caller] That reads as correct. It is also the pattern this page measures, and on a synthetic 12-tenant store it produced two failures that raise nothing and log nothing. The caller received 1.80 of the 5 rows requested, on average, across 168 queries - minimum 1, and 98.2% of queries came back short. In the same fixture, 3.20 of the 5 rows in the unfiltered top-5 belonged to other tenants, which means any code path that assembles the prompt before filtering, or simply loses the filter in a refactor, hands other customers’ facts to the model. ...

November 14, 2026 · 12 min · baeseokjae