mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[GH-ISSUE #24095] Bug: Title/tag generation fails with TypeError in background_tasks_handler for direct connection chats #58850
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?
Originally created by @champumbc on GitHub (Apr 24, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/24095
Check Existing Issues
Installation Method
Docker (ECS Fargate)
Open WebUI Version
v0.9.2
Ollama Version (if applicable)
N/A
Operating System
Linux (AWS Fargate ARM64)
Browser (if applicable)
All browsers
Confirmation
README.md.Related Issue
This is a companion bug to #24092. That issue covers the frontend-initiated HTTP endpoint path (
POST /api/v1/tasks/title/completions). This issue covers the internal middleware path wherebackground_tasks_handlertriggers title/tag generation automatically after a chat completion.Expected Behavior
After a chat completion finishes via a direct connection model, the middleware's
background_tasks_handlershould generate a title and tags using the configured Task Model (e.g., "Amazon Nova Micro" configured in Admin > Settings), making a server-side API call.Actual Behavior
Title and tag generation crashes with
TypeError: 'NoneType' object is not callable. The chat title falls back to displaying the user's first message instead of a generated title.Full traceback from server logs:
Root Cause
There are two compounding issues:
1.
request.state.directpersists into background task generation:When
background_tasks_handler(middleware.py:3001) callsgenerate_title(request, ...), it passes the original request object from the chat completion. This request still hasrequest.state.direct = Trueset from the user's direct connection chat.In
generate_title(tasks.py:~160), this causes:2. Task model override fails because models dict is too narrow:
get_task_model_id(utils/task.py) tries to find the configured Task Model ("Amazon Nova Micro") in themodelsdict, butmodelsonly contains the direct connection model (e.g., "Claude Haiku 4.5"). The override never happens:3. Direct completion path crashes:
Since
request.state.directis True,generate_chat_completion(chat.py:196) routes togenerate_direct_chat_completion. This function callsevent_caller = await get_event_call(metadata)(chat.py:75), which returnsNonebecause the background task context doesn't have a valid WebSocket session. Thenres = await event_caller({...})at line 140 crashes.Steps to Reproduce
ENABLE_DIRECT_CONNECTIONS=trueandENABLE_OLLAMA_API=FalseSuggested Fix
The
background_tasks_handlershould ensure that task generation uses the server-side path when the resolved task model is a server-level model:Option A: Clear
request.state.directbefore calling task functions:Option B: Have
get_task_model_idfall back torequest.app.state.MODELSwhen the configured task model isn't in the narrow direct-connection models dict.Option C: Have
generate_title/generate_chat_tagscheck whether the resolvedtask_model_idis a server-side model and explicitly userequest.app.state.MODELSfor the completion call in that case.Option A is the simplest and most targeted fix.
Environment
ENABLE_DIRECT_CONNECTIONS=trueENABLE_OLLAMA_API=False@champumbc commented on GitHub (Apr 24, 2026):
In full disclosure, again, I did use Claude Code to help write and file the issue - but the problem is confirmed by a real human, me.
@champumbc commented on GitHub (Apr 24, 2026):
PR with fix: https://github.com/open-webui/open-webui/pull/24099
@champumbc commented on GitHub (Apr 24, 2026):
PR with fix: https://github.com/open-webui/open-webui/pull/24100 (replaces #24099 which had wrong base branch)