supermemory
supermemory copied to clipboard
Vector‑Searchable Conversational Memory
✨ Feature Proposal — Vector‑Searchable Conversational Memory
Embed salient chat turns & surface them through the existing POST /search endpoint.
1 · Why This Matters
-
POST /chatsaves entire transcripts inchatThreads.messages(JSONB) but does not embed individual turns. -
POST /searchonly returns document chunks, so past chat decisions are invisible. - External tools (Open WebUI, Cursor, Goose, Flowise) want a single memory store that serves both docs and chat snippets.
2 · Design Goals
-
Searchable – useful chat turns appear in
/searchresults. - Lean & Scalable – skip filler messages; allow configurable policies.
- Opt‑in & Non‑breaking – defaults keep current behaviour.
-
No new endpoints – reuse
POST /search.
3 · Proposed Change (high level)
-
Schema – add a child table
chat_message_embeddings-
idbigserial primary key -
threadId→chatThreads.uuid -
role(user / assistant),text,ts -
embeddingpgvector(768) -
metadataJSONB (e.g.,{ "source": "webui" })
-
-
Write path (
POST /chat)- Feature‑flagged by
ENABLE_CHAT_MEMORY. - After each user turn and assistant reply, call the existing embedding model if
shouldEmbed(text, policy)returns true, then insert intochat_message_embeddings.
- Feature‑flagged by
-
Search path (
POST /search)- Extend current SQL helper:
- When body includes
"includeChats": trueand feature flag on,UNIONchat‑message rows with document chunks. - Return objects with
"src": "doc" | "chat"so clients can badge origin.
- When body includes
- Extend current SQL helper:
-
Config Flags
-
ENABLE_CHAT_MEMORY=false(default) -
CHAT_EMBED_POLICY=salient(off,all,salient,summary_only) -
CHAT_EMBED_MIN_LEN=10 -
CHAT_SUMMARY_EVERY=20(placeholder for future summary tier)
-
4 · Benefits
-
Users – Can ask “What did we rename
tick()to?” and get a chat citation. -
Tools – Just add
"includeChats": trueto/search; no extra endpoint. -
Maintainers – Mirrors existing
documents → chunkspattern; default opt‑out means zero impact on current installs.
5 · Open Questions
- Table name: keep
chat_message_embeddingsor preferchat_messageswith embedded vector column? - Default embed policy:
salientvs.summary_only. - Would a richer filter DSL (
"type": ["doc","chat"]) be better than the booleanincludeChatsflag?
6 · Next Steps (if accepted)
- Drizzle migration for new table.
- Patch
/chatwrite path under feature flag. - Refactor search helper and extend
POST /search. - Add README docs & cURL examples.
- (Optional) unit tests for
shouldEmbed().
Happy to raise a PR implementing the above once we converge on details.