[PR #24921] fix: apply RAG_EMBEDDING_QUERY_PREFIX to memory search queries #131590

Open
opened 2026-05-21 17:16:52 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/24921
Author: @TipKnuckle
Created: 5/19/2026
Status: 🔄 Open

Base: devHead: fix/memory-query-embedding-prefix


📝 Commits (1)

  • 54dd0ec fix: apply RAG_EMBEDDING_QUERY_PREFIX to memory search queries

📊 Changes

1 file changed (+2 additions, -1 deletions)

View changed files

📝 backend/open_webui/routers/memories.py (+2 -1)

📄 Description

Before submitting, make sure you've checked the following:

  • Linked Issue/Discussion: Relates to the RAG_EMBEDDING_QUERY_PREFIX env var added for instruction-tuned embedding models
  • Target branch: dev
  • Description: Concise description below
  • Testing: Manually verified with Qwen3-Embedding; memory search returns semantically correct results with prefix configured, and behaves identically to before when prefix is unset
  • Agentic AI Code: This PR was not written by an AI agent
  • Code review: Self-reviewed

Description

query_memory in routers/memories.py embeds the search query without applying RAG_EMBEDDING_QUERY_PREFIX. Every RAG retrieval path in retrieval/utils.py correctly passes this prefix when calling the embedding function, but the memory search path was missed.

Instruction-tuned embedding models (e.g. Qwen3-Embedding) require a task instruction prefix to produce meaningful query embeddings. Without it, memory search returns semantically unrelated results regardless of what the user searches for — the env var has no effect on memory queries.

Changelog Entry

Fixed

  • Memory search queries now respect RAG_EMBEDDING_QUERY_PREFIX, fixing broken semantic search for instruction-tuned embedding models (e.g. Qwen3-Embedding)

Contributor License Agreement


🔄 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/24921 **Author:** [@TipKnuckle](https://github.com/TipKnuckle) **Created:** 5/19/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/memory-query-embedding-prefix` --- ### 📝 Commits (1) - [`54dd0ec`](https://github.com/open-webui/open-webui/commit/54dd0ec4c46adf749d8911a575c185e1efcd459c) fix: apply RAG_EMBEDDING_QUERY_PREFIX to memory search queries ### 📊 Changes **1 file changed** (+2 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/memories.py` (+2 -1) </details> ### 📄 Description **Before submitting, make sure you've checked the following:** - [x] **Linked Issue/Discussion:** Relates to the `RAG_EMBEDDING_QUERY_PREFIX` env var added for instruction-tuned embedding models - [x] **Target branch:** `dev` - [x] **Description:** Concise description below - [x] **Testing:** Manually verified with Qwen3-Embedding; memory search returns semantically correct results with prefix configured, and behaves identically to before when prefix is unset - [x] **Agentic AI Code:** This PR was not written by an AI agent - [x] **Code review:** Self-reviewed ## Description `query_memory` in `routers/memories.py` embeds the search query without applying `RAG_EMBEDDING_QUERY_PREFIX`. Every RAG retrieval path in `retrieval/utils.py` correctly passes this prefix when calling the embedding function, but the memory search path was missed. Instruction-tuned embedding models (e.g. Qwen3-Embedding) require a task instruction prefix to produce meaningful query embeddings. Without it, memory search returns semantically unrelated results regardless of what the user searches for — the env var has no effect on memory queries. # Changelog Entry ### Fixed - Memory search queries now respect `RAG_EMBEDDING_QUERY_PREFIX`, fixing broken semantic search for instruction-tuned embedding models (e.g. Qwen3-Embedding) --- ### Contributor License Agreement - [x] 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-05-21 17:16:52 -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#131590