From ce4dca47cb19a6582fd8a550806c89ab297c038d Mon Sep 17 00:00:00 2001 From: Craig <66838006+TipKnuckle@users.noreply.github.com> Date: Mon, 1 Jun 2026 13:23:15 -0700 Subject: [PATCH] fix: apply RAG_EMBEDDING_QUERY_PREFIX to memory search queries (#24921) The query_memory endpoint embeds the search query without the configured RAG_EMBEDDING_QUERY_PREFIX, while every RAG retrieval path in retrieval/utils.py correctly passes it. Instruction-tuned embedding models (e.g. Qwen3-Embedding) produce poor results without the prefix, causing memory search to return semantically unrelated results. --- backend/open_webui/routers/memories.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/routers/memories.py b/backend/open_webui/routers/memories.py index e2086609ae..226a64e310 100644 --- a/backend/open_webui/routers/memories.py +++ b/backend/open_webui/routers/memories.py @@ -9,6 +9,7 @@ from open_webui.constants import ERROR_MESSAGES from open_webui.internal.db import get_async_session from open_webui.models.memories import Memories, MemoryModel from open_webui.retrieval.vector.async_client import ASYNC_VECTOR_DB_CLIENT +from open_webui.config import RAG_EMBEDDING_QUERY_PREFIX from open_webui.utils.access_control import has_permission from open_webui.utils.auth import get_verified_user from pydantic import BaseModel @@ -137,7 +138,7 @@ async def query_memory( if not memories: raise HTTPException(status_code=404, detail='No memories found for user') - vector = await request.app.state.EMBEDDING_FUNCTION(form_data.content, user=user) + vector = await request.app.state.EMBEDDING_FUNCTION(form_data.content, RAG_EMBEDDING_QUERY_PREFIX, user=user) results = await ASYNC_VECTOR_DB_CLIENT.search( collection_name=f'user-memory-{user.id}',