Skip to content

fix(memory): increment retrieval_count in retrieval.search() (#17899) - #17910

Closed
luyao618 wants to merge 1 commit into
NousResearch:mainfrom
luyao618:fix/holographic-retrieval-count-never-incremented
Closed

fix(memory): increment retrieval_count in retrieval.search() (#17899)#17910
luyao618 wants to merge 1 commit into
NousResearch:mainfrom
luyao618:fix/holographic-retrieval-count-never-incremented

Conversation

@luyao618

Copy link
Copy Markdown
Contributor

Summary

retrieval.search() — the code path used by both prefetch() and fact_store(action='search') — never incremented the retrieval_count column in the facts table. The column stayed at 0 for every fact, breaking downstream consumers like fact-store-dreaming that rely on usage metrics to identify orphan/stale facts.

Root Cause

Two search paths exist:

  1. store.search_facts() (store.py) — correctly increments retrieval_count, but nothing calls it
  2. retrieval.search() (retrieval.py) — the actual path used everywhere, goes through _fts_candidates() with direct SQL and never increments the counter

Changes

  • plugins/memory/holographic/retrieval.py: Added UPDATE facts SET retrieval_count = retrieval_count + 1 after search() collects results, wrapped in try/except so counter failures never block searches
  • tests/plugins/memory/test_holographic_retrieval_count.py: New test verifying retrieval_count increments on each search() call

Testing

pytest tests/plugins/memory/test_holographic_retrieval_count.py -v  # 1 passed

Closes #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 Apr 30, 2026
…earch#17899)

retrieval.search() — the code path used by both prefetch() and
fact_store(action='search') — never incremented the retrieval_count
column, making it permanently 0 for every fact. This broke downstream
consumers like fact-store-dreaming that rely on usage metrics.

Add the UPDATE statement after results are collected, matching what
store.search_facts() already does. Wrapped in try/except so a counter
failure never blocks a search.

Closes NousResearch#17899
@luyao618

Copy link
Copy Markdown
Contributor Author

Closing: this PR has been open for 1-2 weeks with no maintainer review and the codebase continues to evolve. Will re-submit if the fix is still relevant.

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

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have 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()

2 participants