Skip to content

feat(memory): add SQLite FTS5 search index and memory_search tool (#616) - #632

Open
cagdasyurekli wants to merge 1 commit into
andrewyng:mainfrom
cagdasyurekli:feat/issue-616-memory-fts5-search
Open

feat(memory): add SQLite FTS5 search index and memory_search tool (#616)#632
cagdasyurekli wants to merge 1 commit into
andrewyng:mainfrom
cagdasyurekli:feat/issue-616-memory-fts5-search

Conversation

@cagdasyurekli

Copy link
Copy Markdown

Closes #616

Summary

This PR implements full-text search indexing for SQLiteMemoryStore using SQLite's built-in FTS5 extension:

  • Creates companion virtual table memories_fts with external content table semantics (content=memories, content_rowid=id).
  • Keeps memories_fts automatically synchronized with memories via SQLite AFTER INSERT, AFTER DELETE, and AFTER UPDATE triggers.
  • Automatically rebuilds the FTS index when initializing over an existing database with pre-existing memories.
  • Adds an abstract search() method to MemoryStore and implements it in SQLiteMemoryStore with tokenized prefix matching, rank ordering, and scope/workspace filtering (matching global memories and current workspace memories).
  • Implements graceful fallback to LIKE matching if SQLite lacks FTS5 or encounters operational errors.
  • Exposes memory_search(query: str, limit: int = 5) tool through memory_tools() to allow agents to search relevant facts on demand.
  • Adds comprehensive unit test coverage in tests/test_memory.py.

Verification

  • pytest tests/test_memory.py tests/test_projects.py (64/64 passed).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] SQLite FTS5 search index for SQLiteMemoryStore

1 participant