mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[PR #22331] [CLOSED] fix: preserve edited message content when enriching with DB output items #49665
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/22331
Author: @Classic298
Created: 3/6/2026
Status: ❌ Closed
Base:
dev← Head:fix/edited-message-content-lost📝 Commits (2)
6c256b0fix: preserve edited message content when loading from DB0e5702afix: preserve edited message content when enriching with DB output items📊 Changes
1 file changed (+36 additions, -5 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+36 -5)📄 Description
fix: preserve edited message content when enriching with DB output items
Fixes #22327
Problem
When a user edits an assistant's response (e.g., changing "Cerulean" to "Yellow") and then sends a follow-up message, the LLM receives the original unedited content instead of the edited version. This causes the AI to reference information the user explicitly corrected.
Root Cause
In process_chat_payload, the backend loads the message chain from the database and fully replaces the frontend-sent messages with the DB-loaded versions. The frontend sends the correct, edited content, but the backend discards it in favor of the (potentially stale) DB content.
This DB-loading feature was introduced to preserve structured output items (for tool call reconstruction) that the frontend strips when building messages. However, its implementation replaced all message fields — including content — rather than merging only the DB-specific fields.
Fix
The frontend messages are now treated as authoritative for content (they reflect user edits). The DB is only used to enrich messages with:
Content from the DB never overwrites the frontend-sent content.
Testing DONE
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.