openworker icon indicating copy to clipboard operation
openworker copied to clipboard

[Feature Request] SQLite FTS5 search index for SQLiteMemoryStore

Open cagdasyurekli opened this issue 3 months ago • 0 comments

Motivation

Currently, SQLiteMemoryStore.list() retrieves memories with a flat SELECT * FROM memories WHERE workspace = ?. As users accumulate memories over weeks of work, injecting all memory summaries into every prompt risks diluting model attention and consuming unnecessary context window tokens.

Proposed Solution

Leverage SQLite's built-in FTS5 (Full-Text Search) extension:

  1. Create a companion virtual table:
    CREATE VIRTUAL TABLE IF NOT EXISTS memories_fts USING fts5(content, summary, content=memories, content_rowid=id);
    
  2. Add a search(query: str, limit: int = 5) method to SQLiteMemoryStore using MATCH ? ORDER BY rank.
  3. Expose a memory_search(query: str) tool to the agent so it can query relevant facts on demand rather than loading all facts upfront.

Implementation Scope & Alignment

  • Scope: ~90–130 lines in coworker/memory/sqlite_store.py and coworker/memory/tools.py.
  • Zero New Dependencies: FTS5 is built into Python's standard library sqlite3.
  • Alignment: Keeps memory 100% local, performant, and lightweight without requiring external vector databases or heavyweight embedding services.

cagdasyurekli avatar Sep 04 '26 14:09 cagdasyurekli