mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[PR #24303] [CLOSED] fix: persist Responses streaming usage #66448
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/24303
Author: @Genmin
Created: 5/1/2026
Status: ❌ Closed
Base:
dev← Head:fix/responses-usage-analytics📝 Commits (10+)
fe6783cMerge pull request #19030 from open-webui/devfc05e0aMerge pull request #19405 from open-webui/deve3faec6Merge pull request #19416 from open-webui/dev9899293Merge pull request #19448 from open-webui/dev140605eMerge pull request #19462 from open-webui/dev6f1486fMerge pull request #19466 from open-webui/devd95f533Merge pull request #19729 from open-webui/deva7271530.6.43 (#20093)6adde20Merge pull request #20394 from open-webui/devf9b0534Merge pull request #20522 from open-webui/dev📊 Changes
3 files changed (+63 additions, -5 deletions)
View changed files
➕
backend/open_webui/test/utils/test_response.py(+37 -0)📝
backend/open_webui/utils/middleware.py(+2 -1)📝
backend/open_webui/utils/response.py(+24 -4)📄 Description
Pull Request Checklist
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.fixprefix.Summary
Fixes #24217.
Related to #24294.
This fixes Admin Analytics token accounting for OpenAI Responses API streaming chats. The streaming path already receives final usage metadata on the
response.completedevent, but the metadata was not being normalized into the usage shape saved with the chat event, so analytics could count messages while showing zero tokens.Testing
response.completedpayload includes usage.Commands run:
PYTHONPATH=backend uv run --no-sync --with pytest --with typer --with uvicorn pytest backend/open_webui/test/utils/test_response.py -quv run --no-sync --with ruff ruff check backend/open_webui/utils/response.py backend/open_webui/test/utils/test_response.pypython3 -m compileall -q backend/open_webui/utils/response.py backend/open_webui/utils/middleware.py backend/open_webui/test/utils/test_response.pygit diff --checkScreenshots/videos are not applicable for this backend metadata normalization fix; the regression test directly covers the previously missing persisted usage shape.
Changelog Entry
Description
response.completedevents so Admin Analytics can aggregate it.Added
Changed
Deprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
Screenshots or Videos
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.