[PR #21810] [CLOSED] fix: preserve assistant pre-fill for Continue Response #41917

Closed
opened 2026-04-25 14:00:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21810
Author: @andrewmm511
Created: 2/24/2026
Status: Closed

Base: devHead: fix/continue-response-prefill


📝 Commits (1)

  • 17601bd fix: preserve assistant pre-fill when loading messages from DB

📊 Changes

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

View changed files

📝 backend/open_webui/utils/middleware.py (+13 -1)

📄 Description

Pull Request Checklist

  • Target branch: Verify that the pull request targets the dev branch.
  • Description: Provided below.
  • Changelog: Included below.
  • Documentation: No user-facing documentation changes needed.
  • Dependencies: No new or upgraded dependencies.
  • Testing: Manually tested Continue Response with compatible models; verified normal sends, regeneration, and tool calls are unaffected.
  • Code review: Self-reviewed.
  • Git Hygiene: Single atomic commit, rebased on dev.
  • Title Prefix: fix:

Changelog Entry

Description

Since v0.8.0, the "Continue Response" feature no longer works. Models that support pre-fill respond as if answering the user's question fresh instead of continuing from existing content. Editing an assistant message and clicking Continue also fails to use the edited content.

The root cause is load_messages_from_db (introduced in f2aca781c), which replaces frontend-sent messages with DB-loaded messages. It loads the message chain up to parent_message_id (the user message), which excludes the trailing assistant message the frontend includes as a pre-fill for continuation. The LLM therefore receives no assistant pre-fill and generates a fresh response.

Fixed

  • Preserve the assistant pre-fill message when load_messages_from_db replaces frontend messages, so "Continue Response" correctly provides existing content to the model for continuation.

Additional Information

  • Closes [PR #4788] [MERGED] dev (#21564)
  • The fix captures the last frontend message before DB replacement. If it is an assistant message with non-empty string content (indicating a continuation), it is re-appended after the replacement.
  • Normal message sends, regeneration, and tool call flows are unaffected because their last message is always a user message.

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.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 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/21810 **Author:** [@andrewmm511](https://github.com/andrewmm511) **Created:** 2/24/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/continue-response-prefill` --- ### 📝 Commits (1) - [`17601bd`](https://github.com/open-webui/open-webui/commit/17601bde72c42139f6392ad339ff201de3e08f70) fix: preserve assistant pre-fill when loading messages from DB ### 📊 Changes **1 file changed** (+13 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+13 -1) </details> ### 📄 Description # Pull Request Checklist - [x] **Target branch:** Verify that the pull request targets the `dev` branch. - [x] **Description:** Provided below. - [x] **Changelog:** Included below. - [ ] **Documentation:** No user-facing documentation changes needed. - [ ] **Dependencies:** No new or upgraded dependencies. - [x] **Testing:** Manually tested Continue Response with compatible models; verified normal sends, regeneration, and tool calls are unaffected. - [x] **Code review:** Self-reviewed. - [x] **Git Hygiene:** Single atomic commit, rebased on `dev`. - [x] **Title Prefix:** `fix:` # Changelog Entry ### Description Since v0.8.0, the "Continue Response" feature no longer works. Models that support pre-fill respond as if answering the user's question fresh instead of continuing from existing content. Editing an assistant message and clicking Continue also fails to use the edited content. The root cause is `load_messages_from_db` (introduced in `f2aca781c`), which replaces frontend-sent messages with DB-loaded messages. It loads the message chain up to `parent_message_id` (the user message), which excludes the trailing assistant message the frontend includes as a pre-fill for continuation. The LLM therefore receives no assistant pre-fill and generates a fresh response. ### Fixed - Preserve the assistant pre-fill message when `load_messages_from_db` replaces frontend messages, so "Continue Response" correctly provides existing content to the model for continuation. --- ### Additional Information - Closes #21564 - The fix captures the last frontend message before DB replacement. If it is an assistant message with non-empty string content (indicating a continuation), it is re-appended after the replacement. - Normal message sends, regeneration, and tool call flows are unaffected because their last message is always a user message. ### 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. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <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-25 14:00:17 -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#41917