mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[PR #21583] [CLOSED] fix: skip memory context injection when system prompt is empty #65004
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/21583
Author: @lesj0610
Created: 2/19/2026
Status: ❌ Closed
Base:
main← Head:fix/memory-context-system-prompt-gate📝 Commits (1)
85a0b2eFix memory context injection when system prompt is empty📊 Changes
1 file changed (+13 additions, -3 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+13 -3)📄 Description
Summary
` system messages from being appended.
Why
When the system prompt is intentionally blank, middleware still appended a system message via memory handling. This caused unintended prompt injection and unnecessary context artifacts.
Changes
chat_memory_handler(backend/open_webui/utils/middleware.py):User Contextonly when memory query produced non-empty context.Testing
User Contextsystem message is appended when system prompt is empty.User Contextis appended when system prompt is set and memory returns results.python3 -m compileall backend/open_webui/utils/middleware.pycontributor license agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.