mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 02:48:13 -05:00
[PR #24099] [CLOSED] fix: Task generation failing for direct connection chats #43134
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/24099
Author: @champumbc
Created: 4/24/2026
Status: ❌ Closed
Base:
dev← Head:fix/direct-connection-task-generation📝 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
2 files changed (+94 additions, -97 deletions)
View changed files
📝
backend/open_webui/routers/tasks.py(+78 -97)📝
backend/open_webui/utils/middleware.py(+16 -0)📄 Description
Pull Request Checklist
devbranchContributor License Agreement (CLA)
Summary
Fix title, tag, follow-up, and other task generation endpoints returning 404 or crashing with
TypeError: 'NoneType' object is not callablewhen users chat via direct connections with a server-side task model configured.Changelog Entry
Fixed
Problem
When
ENABLE_DIRECT_CONNECTIONS=trueand users chat with models from their own API keys, all background task generation (auto-title, tags, follow-ups, emoji, etc.) fails:HTTP endpoint path (tasks.py): The model existence check validates the chat model against
request.app.state.MODELSbeforeget_task_model_id()can resolve to the configured task model. Direct connection models aren't in the server's MODELS registry, so this raises a 404 — even though the configured task model is available.Internal middleware path (middleware.py): After a chat completion,
background_tasks_handlercallsgenerate_title/generate_chat_tagswith the original request that still hasrequest.state.direct = True. This routes task generation throughgenerate_direct_chat_completion, which callsget_event_call()— but the WebSocket session isn't available in the background task context, soevent_callerisNoneandawait event_caller({...})crashes with:Changes
backend/open_webui/routers/tasks.pyrequest.app.state.MODELS(server-side models) instead of conditionally using the narrow direct-connection models dictget_task_model_id()and validates the resolvedtask_model_idinstead of the chatmodel_id, allowing the task model override to work for direct connection usersbackend/open_webui/utils/middleware.pybackground_tasks_handlertemporarily clearsrequest.state.directandrequest.state.modelbefore running task generation, sogenerate_chat_completionroutes through the standard server-side pathTesting
Tested on a production AWS Fargate deployment (3 ECS tasks, Aurora PostgreSQL, ALB) with:
ENABLE_DIRECT_CONNECTIONS=trueENABLE_OLLAMA_API=FalseBefore fix: Every new chat via direct connection produced
TypeErrorin logs, title fell back to user's first message, tags not generated.After fix: Title and tags auto-generate correctly using the configured task model. Zero errors in logs. Verified via CloudWatch log monitoring.
Test plan
TypeErroror 404 errors in server logs after chat completions/api/v1/tasks/config) is respected — tasks use the configured task model, not the chat modelRelated Issues
Fixes #24092
Fixes #24095
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.