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:
- Create a companion virtual table:
CREATE VIRTUAL TABLE IF NOT EXISTS memories_fts USING fts5(content, summary, content=memories, content_rowid=id);
- Add a
search(query: str, limit: int = 5) method to SQLiteMemoryStore using MATCH ? ORDER BY rank.
- 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.
Motivation
Currently,
SQLiteMemoryStore.list()retrieves memories with a flatSELECT * 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:
search(query: str, limit: int = 5)method toSQLiteMemoryStoreusingMATCH ? ORDER BY rank.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
coworker/memory/sqlite_store.pyandcoworker/memory/tools.py.sqlite3.