[PR #18565] feat(memory): enhance memory system #47882

Open
opened 2026-04-29 23:17:32 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/18565
Author: @Davixk
Created: 10/23/2025
Status: 🔄 Open

Base: dev ← Head: feat/improve-memory-system


📝 Commits (2)

  • 4a22f14 feat(memory): enhance memory controls and retrieval
  • 993fbce feat(admin): enhance memory settings UX and defaults

📊 Changes

8 files changed (+315 additions, -59 deletions)

View changed files

📝 backend/open_webui/config.py (+18 -0)
📝 backend/open_webui/main.py (+8 -0)
📝 backend/open_webui/routers/auths.py (+46 -36)
📝 backend/open_webui/utils/middleware.py (+47 -12)
📝 src/lib/apis/memories/index.ts (+28 -0)
📝 src/lib/components/admin/Settings/General.svelte (+147 -0)
📝 src/lib/components/chat/Chat.svelte (+1 -1)
📝 src/lib/components/chat/Settings/Personalization.svelte (+20 -10)

📄 Description

Pull Request Checklist

  • Target branch: Verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request down below.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: If necessary, update relevant documentation.
  • Dependencies: No new dependencies added.
  • Testing: Manual tests performed to verify the implemented features work as intended.
  • Agentic AI Code: This PR has gone through human review and manual testing.
  • Code review: Self-review performed, code adheres to project standards.
  • Title Prefix: feat - Introduces new features and enhancements to memory functionality.

Changelog Entry

Description

This pull request significantly enhances the memory system in Open WebUI by introducing granular control over memory retrieval, improved semantic search capabilities, and administrative controls for memory management. The changes provide better control over memory quality and relevance through configurable thresholds and top-k parameters, while also adding the ability to force-enable memory for non-admin users.

Added

  • Memory Top K Configuration: Configurable parameter to control the maximum number of memories retrieved (default: 30)
  • Memory Relevance Threshold: New slider control (0-100%) to set minimum similarity threshold for memory retrieval (default: 50%)
  • Memory Vector Re-indexing: Button in admin settings to re-index all memories using the current embedding model
  • Enhanced Memory Metadata: Memory items now include timestamps (created_at, updated_at) and similarity scores in ISO format
  • Memory Filtering: Automatic filtering of low-relevance memories based on threshold during retrieval
  • Force Enable Memory: New admin setting to force-enable memory for non-admin users, preventing them from disabling it
  • Improved Memory Injection Format: Memories now injected as structured JSON within XML tags (<memory_user_context>) for better LLM parsing

Changed

  • Memory Default State: Changed default memory state from false to true for better user experience
  • Memory Context Format: Memories now formatted as JSON objects with metadata instead of plain text list
  • Memory Logging: Enhanced logging with error/info levels and detailed statistics about retrieved and filtered memories
  • Memory UI: Non-admin users no longer see memory toggle when force-enable is active
  • Backend Structure: Refactored imports in auths.py for better organization (alphabetical ordering)

Fixed

  • Memory Error Handling: Improved error logging when memory queries fail, providing better debugging information

Security

  • No security-related changes

Breaking Changes

  • BREAKING CHANGE: Memory injection format changed from plain text to JSON structure.
  • BREAKING CHANGE: Default memory state changed from disabled to enabled.

Additional Information

The enhanced memory system provides administrators with fine-grained control over memory retrieval quality and allows for optimization of the memory experience across different embedding models. The relevance threshold and top-k parameters can be tuned based on the specific embedding model used and the desired balance between recall and precision.

Key Configuration Parameters:

  • FORCE_ENABLE_MEMORY: Boolean to force memory enabled for non-admin users
  • MEMORY_TOP_K: Integer (1-100), controls max memories retrieved
  • MEMORY_RELEVANCE_THRESHOLD: Float (0.0-1.0), controls minimum similarity score

Use Cases for Re-indexing:

  • After switching embedding models
  • After upgrading embedding model versions
  • When memory retrieval quality degrades over time

Screenshots or Videos

image

Admin Settings - Memory Configuration Section:

  • Force Enable Memory toggle
  • Re-index Memory Vectors button with tooltip
  • Memory Top K input field (numeric, 1-100)
  • Memory Relevance Threshold slider with percentage display (0-100%)

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.


🔄 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/open-webui/open-webui/pull/18565 **Author:** [@Davixk](https://github.com/Davixk) **Created:** 10/23/2025 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `feat/improve-memory-system` --- ### 📝 Commits (2) - [`4a22f14`](https://github.com/open-webui/open-webui/commit/4a22f14a6f2fbeebc5475b7bcb8401425966e21e) feat(memory): enhance memory controls and retrieval - [`993fbce`](https://github.com/open-webui/open-webui/commit/993fbce9dc13655015b4c96d10b949eecd7ca311) feat(admin): enhance memory settings UX and defaults ### 📊 Changes **8 files changed** (+315 additions, -59 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/config.py` (+18 -0) 📝 `backend/open_webui/main.py` (+8 -0) 📝 `backend/open_webui/routers/auths.py` (+46 -36) 📝 `backend/open_webui/utils/middleware.py` (+47 -12) 📝 `src/lib/apis/memories/index.ts` (+28 -0) 📝 `src/lib/components/admin/Settings/General.svelte` (+147 -0) 📝 `src/lib/components/chat/Chat.svelte` (+1 -1) 📝 `src/lib/components/chat/Settings/Personalization.svelte` (+20 -10) </details> ### 📄 Description # Pull Request Checklist - [x] **Target branch:** Verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request down below. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** If necessary, update relevant documentation. - [x] **Dependencies:** No new dependencies added. - [x] **Testing:** Manual tests performed to verify the implemented features work as intended. - [x] **Agentic AI Code:** This PR has gone through human review and manual testing. - [x] **Code review:** Self-review performed, code adheres to project standards. - [x] **Title Prefix:** `feat` - Introduces new features and enhancements to memory functionality. # Changelog Entry ### Description This pull request significantly enhances the memory system in Open WebUI by introducing granular control over memory retrieval, improved semantic search capabilities, and administrative controls for memory management. The changes provide better control over memory quality and relevance through configurable thresholds and top-k parameters, while also adding the ability to force-enable memory for non-admin users. ### Added - **Memory Top K Configuration**: Configurable parameter to control the maximum number of memories retrieved (default: 30) - **Memory Relevance Threshold**: New slider control (0-100%) to set minimum similarity threshold for memory retrieval (default: 50%) - **Memory Vector Re-indexing**: Button in admin settings to re-index all memories using the current embedding model - **Enhanced Memory Metadata**: Memory items now include timestamps (created_at, updated_at) and similarity scores in ISO format - **Memory Filtering**: Automatic filtering of low-relevance memories based on threshold during retrieval - **Force Enable Memory**: New admin setting to force-enable memory for non-admin users, preventing them from disabling it - **Improved Memory Injection Format**: Memories now injected as structured JSON within XML tags (`<memory_user_context>`) for better LLM parsing ### Changed - **Memory Default State**: Changed default memory state from `false` to `true` for better user experience - **Memory Context Format**: Memories now formatted as JSON objects with metadata instead of plain text list - **Memory Logging**: Enhanced logging with error/info levels and detailed statistics about retrieved and filtered memories - **Memory UI**: Non-admin users no longer see memory toggle when force-enable is active - **Backend Structure**: Refactored imports in `auths.py` for better organization (alphabetical ordering) ### Fixed - **Memory Error Handling**: Improved error logging when memory queries fail, providing better debugging information ### Security - No security-related changes ### Breaking Changes - **BREAKING CHANGE**: Memory injection format changed from plain text to JSON structure. - **BREAKING CHANGE**: Default memory state changed from disabled to enabled. --- ### Additional Information The enhanced memory system provides administrators with fine-grained control over memory retrieval quality and allows for optimization of the memory experience across different embedding models. The relevance threshold and top-k parameters can be tuned based on the specific embedding model used and the desired balance between recall and precision. **Key Configuration Parameters:** - `FORCE_ENABLE_MEMORY`: Boolean to force memory enabled for non-admin users - `MEMORY_TOP_K`: Integer (1-100), controls max memories retrieved - `MEMORY_RELEVANCE_THRESHOLD`: Float (0.0-1.0), controls minimum similarity score **Use Cases for Re-indexing:** - After switching embedding models - After upgrading embedding model versions - When memory retrieval quality degrades over time ### Screenshots or Videos <img width="1086" height="1192" alt="image" src="https://github.com/user-attachments/assets/31506d24-ff49-473a-a946-18be511e598d" /> *Admin Settings - Memory Configuration Section:* - Force Enable Memory toggle - Re-index Memory Vectors button with tooltip - Memory Top K input field (numeric, 1-100) - Memory Relevance Threshold slider with percentage display (0-100%) ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-29 23:17:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#47882