Skip to content

fix(memory): increment retrieval_count on search results in holographic memory (#17899) - #39664

Open
dusterbloom wants to merge 1 commit into
NousResearch:mainfrom
dusterbloom:fix/holographic-retrieval-count
Open

fix(memory): increment retrieval_count on search results in holographic memory (#17899)#39664
dusterbloom wants to merge 1 commit into
NousResearch:mainfrom
dusterbloom:fix/holographic-retrieval-count

Conversation

@dusterbloom

Copy link
Copy Markdown
Contributor

Fixes #17899

FactRetriever.search() bypassed store.search_facts(), the only place that bumped retrieval_count. The counter was always 0.

Fix: Increment retrieval_count directly in FactRetriever.search() for returned facts, with silent error handling.

Tests: 3 tests — increments on search, accumulates across multiple searches, unrelated facts stay at 0.

This was originally part of #23221 — split into focused single-fix PRs for easier review.

…ic memory (NousResearch#17899)

FactRetriever.search() bypassed store.search_facts(), the only place
that bumped retrieval_count. The counter was always 0.

Fix: increment retrieval_count directly in FactRetriever.search() for
returned facts, with silent error handling.

Closes NousResearch#17899
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers labels Jun 5, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating a real current-main counter defect. FactRetriever.search() still returns results without updating retrieval_count (plugins/memory/holographic/retrieval.py:106-112), while the active provider uses that method for prefetch and fact_store(action='search') (plugins/memory/holographic/__init__.py:206-210, 284-291).

Problems

  • This fixes only the keyword-search route. probe(), related(), reason(), and _score_facts_by_vector() also return fact lists without recording retrievals (plugins/memory/holographic/retrieval.py:189, 258, 336, 479); the provider exposes the structural routes via fact_store (plugins/memory/holographic/__init__.py:293-313). The linked #55729 correctly identifies this broader sibling set.
  • The added direct write bypasses the shared store lock. MemoryStore documents one shared connection plus one re-entrant lock for serialized access (plugins/memory/holographic/store.py:101-112), and its existing counter update is inside with self._lock (store.py:245, 280-287).

Suggested changes

  • Add a locked store helper for marking returned fact IDs, reuse it from search_facts(), and invoke it from every retriever path that returns facts.
  • Add provider-level tests for keyword and structural retrieval paths, including unchanged counts for unreturned facts.

Automated hermes-sweeper review.


# Increment retrieval_count for returned facts (fixes #17899)
if results:
try:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please route this through a locked MemoryStore helper rather than writing _conn directly. MemoryStore deliberately shares one SQLite connection and one _lock for serialized access (store.py:101-112); this new write bypasses that contract and duplicates the existing counter SQL in search_facts().

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@teknium1 I've implemented this with the locked MemoryStore helper. Might wanna take a look
And following your suggestion, I've wired all the retrieval paths to increment the count.

#73901

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/memory Memory subsystem: store, providers, sync, background reviews comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Holographic memory: retrieval_count never incremented — search() in retrieval.py bypasses store.search_facts()

4 participants