From 099da45831a56ec106afb5dd4cc8df8cc994e91c Mon Sep 17 00:00:00 2001 From: msaidbilgehan Date: Sat, 18 Apr 2026 20:25:13 +0300 Subject: [PATCH] fix(vector_store): avoid numpy truth-value ambiguity in list-column reads LanceDB returns `keywords`, `persons`, and `entities` columns as numpy arrays when read via `table.to_pandas()`. The existing `row["col"] or []` pattern triggers `ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()` because Python evaluates `bool(array)` for the `or` short-circuit. Replace the three occurrences in `keyword_search` and `structured_search` with the `is not None` idiom already used elsewhere in the file when building `MemoryEntry` objects, so behavior is consistent and safe for numpy-backed rows. --- MCP/server/database/vector_store.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MCP/server/database/vector_store.py b/MCP/server/database/vector_store.py index 00c5fa6d..844a779d 100644 --- a/MCP/server/database/vector_store.py +++ b/MCP/server/database/vector_store.py @@ -190,7 +190,8 @@ async def keyword_search( scores = [] for idx, row in df.iterrows(): score = 0 - entry_keywords = set(k.lower() for k in (row["keywords"] or [])) + row_keywords = row["keywords"] if row["keywords"] is not None else [] + entry_keywords = set(k.lower() for k in row_keywords) entry_text = row["lossless_restatement"].lower() for kw in keywords: @@ -267,7 +268,8 @@ async def structured_search( if persons: persons_lower = set(p.lower() for p in persons) for i, row in df.iterrows(): - row_persons = set(p.lower() for p in (row["persons"] or [])) + persons_val = row["persons"] if row["persons"] is not None else [] + row_persons = set(p.lower() for p in persons_val) if not persons_lower.intersection(row_persons): mask[i] = False @@ -284,7 +286,8 @@ async def structured_search( entities_lower = set(e.lower() for e in entities) for i, row in df.iterrows(): if mask[i]: - row_entities = set(e.lower() for e in (row["entities"] or [])) + entities_val = row["entities"] if row["entities"] is not None else [] + row_entities = set(e.lower() for e in entities_val) if not entities_lower.intersection(row_entities): mask[i] = False