Skip to content

feat(memory): extract and persist fluid memory after chat turns - #166

Merged
EricNGOntos merged 1 commit into
mainfrom
feat/wuchengke/fluid-memory-extract
Sep 1, 2026
Merged

feat(memory): extract and persist fluid memory after chat turns#166
EricNGOntos merged 1 commit into
mainfrom
feat/wuchengke/fluid-memory-extract

Conversation

@EricNGOntos

Copy link
Copy Markdown
Contributor

Summary

Ships Phase 1 fluid memory so successful chat turns extract durable user insights (indicator preferences, stances, decision rules, entities of interest) and persist them per workspace.

  • New tables: fluid_memory_items, memory_diffs, and fluid_memory_tokens (lexical inverted index for dedup candidate retrieval; no pgvector).
  • After a chat answer succeeds, fire-and-forget QStash workflow POST /api/memory/extract loads the turn, retrieves lexically similar active memories by kind, runs structured LLM extraction, then applies create/skip/merge/deprecate with audit diffs.
  • Write path keeps tokens in sync with active items; merge unions aliases (and entity document ids) so prior search terms are not wiped; payloads with no searchable tokens are skipped.
  • Isolation is by workspaceId (one workspace per user), so users do not share memory rows.

Why

Offline/crystal document memory alone is not enough for personal cognition. This lands the online fluid-memory capture path required before activating offline facts with user-owned indicators and entities.

Test plan

  • tsc --noEmit clean on changed tree
  • eslint on memory + chat trigger paths
  • Vitest: src/domains/memory + chat route trigger coverage
  • Local multi-turn DashScope simulation against Postgres (create/merge/skip paths; token candidate retrieval)
  • After merge: apply drizzle migrations 0013 + 0014 on staging Neon
  • Staging smoke: two users chat → each workspace gets its own fluid_memory_items / tokens / diffs
  • Promote staging-tested commit toward production and migrate production DB similarly

Deploy notes

Staging already has QSTASH_*, NOTEBOOK_PUBLIC_URL, AI_GATEWAY_API_KEY, CHAT_MODEL, and DATABASE_DRIVER=pg. No new required env vars. Optional override: MEMORY_EXTRACTION_MODEL (defaults to CHAT_MODEL).

Made with Cursor

Add workspace-scoped fluid memory tables, lexical dedup token index,
QStash extraction workflow, and fire-and-forget trigger after successful
chat answers so durable user insights are stored for later cognition.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
knowhere-notebook-staging Ready Ready Preview Sep 1, 2026 9:53am UTC
1 Skipped Deployment
Project Deployment Actions Updated
knowhere-notebook Ignored Ignored Sep 1, 2026 9:53am UTC

Request Review

@EricNGOntos EricNGOntos self-assigned this Sep 1, 2026
@EricNGOntos
EricNGOntos merged commit 76ede0f into main Sep 1, 2026
7 checks passed
@EricNGOntos
EricNGOntos deleted the feat/wuchengke/fluid-memory-extract branch September 1, 2026 09:56
EricNGOntos added a commit that referenced this pull request Sep 1, 2026
* feat(chat): add agentic retrieval toggle to chat composer

* feat(chat): refine deep search toggle UI

* feat(memory): extract and persist fluid memory after chat turns (#166)

Add workspace-scoped fluid memory tables, lexical dedup token index,
QStash extraction workflow, and fire-and-forget trigger after successful
chat answers so durable user insights are stored for later cognition.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: suguanYang <wangbinqi77@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant