mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-11 18:43:44 -05:00
[PR #24717] fix: run outlet filters before background title, tags, and follow-ups #115108
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/24717
Author: @jmleksan
Created: 5/14/2026
Status: 🔄 Open
Base:
dev← Head:fix/outlet-run-before-background📝 Commits (1)
f8aa983refactor: move background tasks handler call to ensure consistent execution in chat response handlers📊 Changes
1 file changed (+2 additions, -2 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+2 -2)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request.
This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR.
Before submitting, make sure you've checked the following:
devbranch.CHANGELOG.mdif needed).awaitsequence in chat response handlers only.fix:— bug fix / correctness for downstream tasks and perceived latency ofchat:outlet.Changelog Entry
middleware.py),outlet_filter_handlernow runs beforebackground_tasks_handler(title, tags, follow-ups). Title/tags/suggestions therefore use the same persisted thread content after outlet edits, andchat:outletis no longer deferred behind those extra LLM calls.Description
After a chat completion finishes (streaming and non-streaming), outlet filters (
outlet_filter_handler) now run beforebackground_tasks_handler(title generation, tags generation, follow-up generation).Previously, background tasks ran first, so title, tags, and follow-ups were built from
messages_mapbefore outlet filters could persist any assistant message edits. That made metadata and suggestions reflect pre-outlet text while the UI could later show post-outlet content viachat:outlet. Outlet also waited behind extra model calls, sochat:outletcould feel significantly delayed.Impact: Title, tags, and follow-ups now see the same persisted thread content outlet uses;
chat:outletis no longer blocked by those background LLM calls.ctx['assistant_message']is set before outlet so temp/local chats still work for outlet.Changed
backend/open_webui/utils/middleware.py): execution order is nowoutlet_filter_handler→background_tasks_handlerafter the assistant message is saved andchat:completion/doneis emitted (streaming path unchanged for whendonefires; only post-emit work is reordered). Non-streaming path setsctx['assistant_message']before outlet, then outlet, then background tasks.Fixed
chat:outletis emitted before background title/tags/follow-up completions run, instead of after them.Breaking Changes
Additional Information
backend/open_webui/utils/middleware.py(non_streaming_chat_response_handler,streaming_chat_response_handler,outlet_filter_handlerdocstring).content. Confirm DB / UI title and tags reflect edited text (or at least the thread snapshot used for those prompts matches post-outlet).chat:outletstill arrives and updates the client; observe it is not deferred until after title/tags network activity.local:chat: confirm outlet still runs withctx['assistant_message']set.Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.