mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 23:21:44 -05:00
[PR #23615] [CLOSED] Fix: Enable outlet filters for direct API clients by integrating /chat/completed processing into /chat/completion #42907
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/23615
Author: @pfn
Created: 4/12/2026
Status: ❌ Closed
Base:
dev← Head:completed-in-completion📝 Commits (1)
d10bd1dRe-implement /chat/completed in /chat/completion, make completed no-op📊 Changes
2 files changed (+222 additions, -13 deletions)
View changed files
📝
backend/open_webui/main.py(+8 -13)📝
backend/open_webui/utils/middleware.py(+214 -0)📄 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. PRs targetingmainwill be immediately closed.devto ensure no unrelated commits (e.g. frommain) are included. Push updates to the existing PR branch instead of closing and reopening.Changelog Entry
Description
This PR fixes a long-standing issue where direct API clients (e.g., opencode, cline, openclaw, Langfuse integrations) could not trigger outlet filters because they don't call the /api/chat/completed endpoint. Now, outlet filters run universally for all completion requests, regardless of the client type.
Added
Changed
Deprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
Problem
Previously, outlet filters (used for logging, analytics, content moderation, etc.) only executed when the
/api/chat/completedendpoint was called. The Web UI calls this endpoint after receiving a completion response, but direct API clients typically don't know about this endpoint and never call it. This meant:Solution
Outlet filter processing has been moved from
/api/chat/completedinto the/api/chat/completionendpoint itself. Outlet filters now run as the final step of the completion flow, after background tasks (title generation, tag generation, etc.) but before the response is returned to the client.Key Decision: Outlet filters run after background tasks (not before). This ensures that title and tag generation complete first, so outlet filters see the final state. An alternative design could run outlet filters before background tasks, but that would mean filters wouldn't see generated titles/tags. This matches the behavior as if calling /chat/completed
Testing
Basic testing has been performed with the following scenarios:
All of these scenarios have been verified to show up in langfuse (pipeline filter) and work correctly with my own filters that I have installed.
Backward Compatibility
/api/chat/completedremains functional: Returns input payload unchanged (no-op)Performance Considerations
Notes
Screenshots or Videos
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.