[PR #5269] [MERGED] feat: Memories/Personalization #5383

Closed
opened 2026-06-05 15:21:10 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/5269
Author: @shatfield4
Created: 3/25/2026
Status: Merged
Merged: 5/19/2026
Merged by: @timothycarambat

Base: masterHead: feat/memory


📝 Commits (10+)

  • 039df69 add memory storage layer with model, endpoints, schema, and system setting
  • 77f5e29 add memory extraction background worker
  • dc0ca66 handle single-user and multi-user mode for memory extraction
  • c758100 add memory injection and personalization ui
  • 2bdd852 lint
  • 4dcff15 personalization UI polish, fix RBAC for all roles, and endpoint guards
  • 4c7c917 split admin personalization page into subcomponents
  • dea632c split admin personalization page into subcomponents, use early return instead of ternary for readability
  • b7c096a make error responses consistent in memory endpoints
  • efd6e6e consolidate duplicate MemoryItem into shared component

📊 Changes

64 files changed (+3709 additions, -148 deletions)

View changed files

📝 docker/.env.example (+12 -0)
📝 frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Citation/index.jsx (+1 -1)
frontend/src/components/WorkspaceChat/ChatContainer/ChatSettingsMenu/Memories/index.jsx (+41 -0)
frontend/src/components/WorkspaceChat/ChatContainer/ChatSettingsMenu/TextSize/index.jsx (+81 -0)
frontend/src/components/WorkspaceChat/ChatContainer/ChatSettingsMenu/index.jsx (+66 -0)
frontend/src/components/WorkspaceChat/ChatContainer/ChatSidebar/index.jsx (+80 -0)
frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/MemoriesContext.jsx (+132 -0)
frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/MemoryCard/CardMenu/index.jsx (+71 -0)
frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/MemoryCard/index.jsx (+86 -0)
frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/MemoryModal/index.jsx (+107 -0)
frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/MemoryTabs/index.jsx (+73 -0)
frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/PersonalizationToggle/index.jsx (+73 -0)
frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/index.jsx (+137 -0)
📝 frontend/src/components/WorkspaceChat/ChatContainer/SourcesSidebar/index.jsx (+7 -34)
📝 frontend/src/components/WorkspaceChat/ChatContainer/index.jsx (+56 -46)
📝 frontend/src/locales/ar/common.js (+36 -0)
📝 frontend/src/locales/ca/common.js (+37 -0)
📝 frontend/src/locales/cs/common.js (+37 -0)
📝 frontend/src/locales/da/common.js (+37 -0)
📝 frontend/src/locales/de/common.js (+37 -0)

...and 44 more files

📄 Description

Pull Request Type

  • feat (New feature)
  • 🐛 fix (Bug fix)
  • ♻️ refactor (Code refactoring without changing behavior)
  • 💄 style (UI style changes)
  • 🔨 chore (Build, CI, maintenance)
  • 📝 docs (Documentation updates)

Relevant Issues

resolves #5276
resolves #5389

Translations PR: https://github.com/Mintplex-Labs/anything-llm/pull/5661
Docs PR: https://github.com/Mintplex-Labs/anythingllm-docs/pull/235

Description

  • Added a new memories database table with Prisma schema and migration for storing user memories scoped to global or per-workspace
  • Added a Memory server model with full CRUD, promote-to-global, replace workspace memories, and multi-user migration support
  • Added memoryProcessed flag to workspace_chats table to track which chats have been processed for memory extraction
  • Added server API endpoints for memories (list, create, update, delete, promote to global, clear all, run extraction)
  • Added a memoryEnabled middleware guard on all memory endpoints so they 403 when the feature is off
  • Added ownership checks on memory update/delete/promote so users can only modify their own memories
  • Added a background worker job (extract-memories) that runs every 15 minutes, uses the workspace LLM to extract memories from unprocessed chats
  • Background extraction skips running if the user has been active in the last 20 minutes to avoid processing mid-conversation
  • Added memory injection into chat system prompts (streaming, sync, and API chat handlers) via a shared promptWithMemories util
  • Memories are reranked against the current prompt + recent history using the native embedding reranker when more than 5 workspace memories exist
  • Added global memory limit of 5 and workspace memory limit of 20, enforced on create and promote
  • Added admin Personalization settings page with toggle to enable/disable the feature, run extraction manually, clear all memories, and manage global memories
  • Added workspace-level Personalization settings tab where users can view, add, edit, delete, and promote workspace memories to global
  • Added Personalization link to the admin settings sidebar
  • Added Personalization tab to workspace settings, visible only when the feature is enabled
  • Default role users can now access workspace settings (only the Personalization tab) when memory is enabled, with proper redirects for all other tabs
  • Added frontend Memory API model for all memory endpoints
  • Added shared MemoryForm and MemoryItem components used across both admin and workspace personalization pages
  • Added memory_enabled to system settings supported/public fields and exposed MemoryEnabled in the system keys response
  • Added single-user to multi-user migration for both memories and workspace chats (assigns orphaned records to the admin user)

Visuals (if applicable)

Screenshot 2026-04-10 at 4 56 50 PM Screenshot 2026-04-10 at 4 56 26 PM Screenshot 2026-04-10 at 4 56 36 PM

Additional Information

  • Test CRUD for all areas where we can add/promote to global memories
  • Throughly test RBAC ensuring memories are paired to user accounts in multi-user mode
  • Ensure pending memories are migrated to the new admin account created when enabling multi-user mode and there are no orphaned memories

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated (if applicable)
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/5269 **Author:** [@shatfield4](https://github.com/shatfield4) **Created:** 3/25/2026 **Status:** ✅ Merged **Merged:** 5/19/2026 **Merged by:** [@timothycarambat](https://github.com/timothycarambat) **Base:** `master` ← **Head:** `feat/memory` --- ### 📝 Commits (10+) - [`039df69`](https://github.com/Mintplex-Labs/anything-llm/commit/039df695b31685d29eb7e7c6d5c31478b2c7a6bf) add memory storage layer with model, endpoints, schema, and system setting - [`77f5e29`](https://github.com/Mintplex-Labs/anything-llm/commit/77f5e29e9912512f4c12267ca2a0b30a7e992f51) add memory extraction background worker - [`dc0ca66`](https://github.com/Mintplex-Labs/anything-llm/commit/dc0ca665863f808f3ccffdedce39f1c17e504e28) handle single-user and multi-user mode for memory extraction - [`c758100`](https://github.com/Mintplex-Labs/anything-llm/commit/c75810012ec2889a8e8e92eca6d5ace85c9e0998) add memory injection and personalization ui - [`2bdd852`](https://github.com/Mintplex-Labs/anything-llm/commit/2bdd8524d20ff1415fb526490fde6030e1f08c7a) lint - [`4dcff15`](https://github.com/Mintplex-Labs/anything-llm/commit/4dcff15b20359e26dd8bf87636ee466e786a1855) personalization UI polish, fix RBAC for all roles, and endpoint guards - [`4c7c917`](https://github.com/Mintplex-Labs/anything-llm/commit/4c7c9176f7db4054a7d8789e8f67d28de9f642e3) split admin personalization page into subcomponents - [`dea632c`](https://github.com/Mintplex-Labs/anything-llm/commit/dea632ce1537f2dc8ce2aa97a04aec12ab4ab0de) split admin personalization page into subcomponents, use early return instead of ternary for readability - [`b7c096a`](https://github.com/Mintplex-Labs/anything-llm/commit/b7c096afd9d7b1764240b94fa5af56ae4710f184) make error responses consistent in memory endpoints - [`efd6e6e`](https://github.com/Mintplex-Labs/anything-llm/commit/efd6e6efa908ca118fb8813b4bef84cd08795869) consolidate duplicate MemoryItem into shared component ### 📊 Changes **64 files changed** (+3709 additions, -148 deletions) <details> <summary>View changed files</summary> 📝 `docker/.env.example` (+12 -0) 📝 `frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Citation/index.jsx` (+1 -1) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/ChatSettingsMenu/Memories/index.jsx` (+41 -0) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/ChatSettingsMenu/TextSize/index.jsx` (+81 -0) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/ChatSettingsMenu/index.jsx` (+66 -0) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/ChatSidebar/index.jsx` (+80 -0) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/MemoriesContext.jsx` (+132 -0) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/MemoryCard/CardMenu/index.jsx` (+71 -0) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/MemoryCard/index.jsx` (+86 -0) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/MemoryModal/index.jsx` (+107 -0) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/MemoryTabs/index.jsx` (+73 -0) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/PersonalizationToggle/index.jsx` (+73 -0) ➕ `frontend/src/components/WorkspaceChat/ChatContainer/MemoriesSidebar/index.jsx` (+137 -0) 📝 `frontend/src/components/WorkspaceChat/ChatContainer/SourcesSidebar/index.jsx` (+7 -34) 📝 `frontend/src/components/WorkspaceChat/ChatContainer/index.jsx` (+56 -46) 📝 `frontend/src/locales/ar/common.js` (+36 -0) 📝 `frontend/src/locales/ca/common.js` (+37 -0) 📝 `frontend/src/locales/cs/common.js` (+37 -0) 📝 `frontend/src/locales/da/common.js` (+37 -0) 📝 `frontend/src/locales/de/common.js` (+37 -0) _...and 44 more files_ </details> ### 📄 Description ### Pull Request Type <!-- For change type, change [ ] to [x]. --> - [x] ✨ feat (New feature) - [ ] 🐛 fix (Bug fix) - [ ] ♻️ refactor (Code refactoring without changing behavior) - [ ] 💄 style (UI style changes) - [ ] 🔨 chore (Build, CI, maintenance) - [ ] 📝 docs (Documentation updates) ### Relevant Issues <!-- Use "resolves #xxx" to auto resolve on merge. Otherwise, please use "connect #xxx" --> resolves #5276 resolves #5389 Translations PR: https://github.com/Mintplex-Labs/anything-llm/pull/5661 Docs PR: https://github.com/Mintplex-Labs/anythingllm-docs/pull/235 ### Description <!-- Describe the changes in this PR that are impactful to the repo. What problem does it solve? --> - Added a new memories database table with Prisma schema and migration for storing user memories scoped to global or per-workspace - Added a Memory server model with full CRUD, promote-to-global, replace workspace memories, and multi-user migration support - Added memoryProcessed flag to workspace_chats table to track which chats have been processed for memory extraction - Added server API endpoints for memories (list, create, update, delete, promote to global, clear all, run extraction) - Added a memoryEnabled middleware guard on all memory endpoints so they 403 when the feature is off - Added ownership checks on memory update/delete/promote so users can only modify their own memories - Added a background worker job (extract-memories) that runs every 15 minutes, uses the workspace LLM to extract memories from unprocessed chats - Background extraction skips running if the user has been active in the last 20 minutes to avoid processing mid-conversation - Added memory injection into chat system prompts (streaming, sync, and API chat handlers) via a shared promptWithMemories util - Memories are reranked against the current prompt + recent history using the native embedding reranker when more than 5 workspace memories exist - Added global memory limit of 5 and workspace memory limit of 20, enforced on create and promote - Added admin Personalization settings page with toggle to enable/disable the feature, run extraction manually, clear all memories, and manage global memories - Added workspace-level Personalization settings tab where users can view, add, edit, delete, and promote workspace memories to global - Added Personalization link to the admin settings sidebar - Added Personalization tab to workspace settings, visible only when the feature is enabled - Default role users can now access workspace settings (only the Personalization tab) when memory is enabled, with proper redirects for all other tabs - Added frontend Memory API model for all memory endpoints - Added shared MemoryForm and MemoryItem components used across both admin and workspace personalization pages - Added memory_enabled to system settings supported/public fields and exposed MemoryEnabled in the system keys response - Added single-user to multi-user migration for both memories and workspace chats (assigns orphaned records to the admin user) ### Visuals (if applicable) <!-- Add screenshots or screen recordings to demonstrate the changes, especially for UI updates. --> <img width="381" height="219" alt="Screenshot 2026-04-10 at 4 56 50 PM" src="https://github.com/user-attachments/assets/3b1d7271-3a69-4609-9c3e-c78cc3d5e067" /> <img width="1813" height="885" alt="Screenshot 2026-04-10 at 4 56 26 PM" src="https://github.com/user-attachments/assets/d4d7ced4-37a0-43cc-8fc6-a39e95aeea31" /> <img width="1814" height="886" alt="Screenshot 2026-04-10 at 4 56 36 PM" src="https://github.com/user-attachments/assets/fbeb789a-b56d-43d9-8dd0-4a03353d1b02" /> ### Additional Information <!-- Add any other context about the Pull Request here that was not captured above. --> - Test CRUD for all areas where we can add/promote to global memories - Throughly test RBAC ensuring memories are paired to user accounts in multi-user mode - Ensure pending memories are migrated to the new admin account created when enabling multi-user mode and there are no orphaned memories ### Developer Validations <!-- All of the applicable items should be checked. --> - [x] I ran `yarn lint` from the root of the repo & committed changes - [x] Relevant documentation has been updated (if applicable) - [x] I have tested my code functionality - [x] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 15:21:10 -04:00
yindo closed this issue 2026-06-05 15:21:11 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#5383