[GH-ISSUE #24092] Bug: Task endpoints (title/tags/follow-up generation) return 404 when chat model is from a direct connection #35710

Open
opened 2026-04-25 09:53:25 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @champumbc on GitHub (Apr 24, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/24092

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Docker (ECS Fargate)

Open WebUI Version

v0.9.2

Ollama Version (if applicable)

N/A (Ollama disabled)

Operating System

Linux (AWS Fargate ARM64)

Browser (if applicable)

All browsers

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation.

Expected Behavior

When a user chats using a model from a direct connection (e.g., gpt-4o via their own OpenAI API key), and a Task Model is configured in Admin Settings (e.g., "Amazon Nova Micro" from a server-level OpenAI connection), the task endpoints (/api/v1/tasks/title/completions, /api/v1/tasks/tags/completions, etc.) should use the configured Task Model to generate titles, tags, follow-ups, etc.

Actual Behavior

All task endpoints return HTTP 404 with "MODEL_NOT_FOUND" when the chat model comes from a direct connection, because the chat model ID is not present in request.app.state.MODELS. The configured Task Model fallback never executes.

Server log:

"POST /api/v1/tasks/title/completions HTTP/1.1" 404

Root Cause

In backend/open_webui/routers/tasks.py, the generate_title function (and all similar task endpoints) validates the chat model before calling get_task_model_id():

@router.post('/title/completions')
async def generate_title(request: Request, form_data: dict, user=Depends(get_verified_user)):
    # ...
    models = request.app.state.MODELS  # Only server-registered models

    model_id = form_data['model']  # e.g., "gpt-4o" from direct connection
    if model_id not in models:
        raise HTTPException(status_code=404)  # <-- Fails here, never reaches fallback

    # This task model fallback is never reached:
    task_model_id = get_task_model_id(
        model_id,
        request.app.state.config.TASK_MODEL,       # "Amazon Nova Micro" (configured)
        request.app.state.config.TASK_MODEL_EXTERNAL,  # "Amazon Nova Micro" (configured)
        models,
    )

The model existence check on the chat model at line ~165 runs before get_task_model_id() at line ~173. Since direct connection models are not in request.app.state.MODELS, the 404 is raised before the task model override can resolve to the configured server-side model.

This same pattern affects all task endpoints: title/completions, tags/completions, follow_up/completions, queries/completions, auto/completions, emoji/completions, moa/completions, and image_prompt/completions.

Steps to Reproduce

  1. Deploy Open WebUI with ENABLE_DIRECT_CONNECTIONS=true and ENABLE_OLLAMA_API=False
  2. Configure a server-level OpenAI connection in Admin > Connections (e.g., an Amazon Bedrock endpoint with "Amazon Nova Micro")
  3. In Admin > Settings > Interface, set both Task Model (Local) and Task Model (External) to the server-level model (e.g., "Amazon Nova Micro")
  4. As a user, add a direct connection (e.g., OpenAI API key with access to gpt-4o)
  5. Start a new chat using the direct connection model (gpt-4o)
  6. Send a message — the chat works, but the automatic title generation fails with a 404
  7. Server logs show: POST /api/v1/tasks/title/completions HTTP/1.1" 404

Suggested Fix

Move the model existence validation to after get_task_model_id() resolves the actual model to be used, and validate the resolved task_model_id instead of the chat model_id:

# Let get_task_model_id resolve first — it may override to a server-level model
task_model_id = get_task_model_id(
    model_id,
    request.app.state.config.TASK_MODEL,
    request.app.state.config.TASK_MODEL_EXTERNAL,
    models,
)

# Validate the resolved task model, not the chat model
if task_model_id not in models:
    raise HTTPException(
        status_code=status.HTTP_404_NOT_FOUND,
        detail=ERROR_MESSAGES.MODEL_NOT_FOUND(),
    )

Note: get_task_model_id() would also need a small adjustment — when the chat model isn't in models, the connection_type lookup fails, so the function should default to trying the external task model when the chat model is unknown:

def get_task_model_id(default_model_id, task_model, task_model_external, models):
    task_model_id = default_model_id
    if models.get(task_model_id, {}).get('connection_type') == 'local':
        if task_model and task_model in models:
            task_model_id = task_model
    else:
        # This branch also handles the case where default_model_id is not in models
        # (e.g., direct connection models), correctly falling back to external task model
        if task_model_external and task_model_external in models:
            task_model_id = task_model_external
    return task_model_id

Environment

  • ENABLE_DIRECT_CONNECTIONS=true
  • ENABLE_OLLAMA_API=False
  • Server-level OpenAI connection configured with models
  • Task Model configured in Admin Settings
  • Multiple users relying on direct connections for chat
Originally created by @champumbc on GitHub (Apr 24, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/24092 ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Docker (ECS Fargate) ### Open WebUI Version v0.9.2 ### Ollama Version (if applicable) N/A (Ollama disabled) ### Operating System Linux (AWS Fargate ARM64) ### Browser (if applicable) All browsers ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. ### Expected Behavior When a user chats using a model from a direct connection (e.g., `gpt-4o` via their own OpenAI API key), and a Task Model is configured in Admin Settings (e.g., "Amazon Nova Micro" from a server-level OpenAI connection), the task endpoints (`/api/v1/tasks/title/completions`, `/api/v1/tasks/tags/completions`, etc.) should use the configured Task Model to generate titles, tags, follow-ups, etc. ### Actual Behavior All task endpoints return HTTP 404 with "MODEL_NOT_FOUND" when the chat model comes from a direct connection, because the chat model ID is not present in `request.app.state.MODELS`. The configured Task Model fallback never executes. **Server log:** ``` "POST /api/v1/tasks/title/completions HTTP/1.1" 404 ``` ### Root Cause In `backend/open_webui/routers/tasks.py`, the `generate_title` function (and all similar task endpoints) validates the chat model **before** calling `get_task_model_id()`: ```python @router.post('/title/completions') async def generate_title(request: Request, form_data: dict, user=Depends(get_verified_user)): # ... models = request.app.state.MODELS # Only server-registered models model_id = form_data['model'] # e.g., "gpt-4o" from direct connection if model_id not in models: raise HTTPException(status_code=404) # <-- Fails here, never reaches fallback # This task model fallback is never reached: task_model_id = get_task_model_id( model_id, request.app.state.config.TASK_MODEL, # "Amazon Nova Micro" (configured) request.app.state.config.TASK_MODEL_EXTERNAL, # "Amazon Nova Micro" (configured) models, ) ``` The model existence check on the **chat model** at line ~165 runs before `get_task_model_id()` at line ~173. Since direct connection models are not in `request.app.state.MODELS`, the 404 is raised before the task model override can resolve to the configured server-side model. This same pattern affects all task endpoints: `title/completions`, `tags/completions`, `follow_up/completions`, `queries/completions`, `auto/completions`, `emoji/completions`, `moa/completions`, and `image_prompt/completions`. ### Steps to Reproduce 1. Deploy Open WebUI with `ENABLE_DIRECT_CONNECTIONS=true` and `ENABLE_OLLAMA_API=False` 2. Configure a server-level OpenAI connection in Admin > Connections (e.g., an Amazon Bedrock endpoint with "Amazon Nova Micro") 3. In Admin > Settings > Interface, set both Task Model (Local) and Task Model (External) to the server-level model (e.g., "Amazon Nova Micro") 4. As a user, add a direct connection (e.g., OpenAI API key with access to `gpt-4o`) 5. Start a new chat using the direct connection model (`gpt-4o`) 6. Send a message — the chat works, but the automatic title generation fails with a 404 7. Server logs show: `POST /api/v1/tasks/title/completions HTTP/1.1" 404` ### Suggested Fix Move the model existence validation to **after** `get_task_model_id()` resolves the actual model to be used, and validate the resolved `task_model_id` instead of the chat `model_id`: ```python # Let get_task_model_id resolve first — it may override to a server-level model task_model_id = get_task_model_id( model_id, request.app.state.config.TASK_MODEL, request.app.state.config.TASK_MODEL_EXTERNAL, models, ) # Validate the resolved task model, not the chat model if task_model_id not in models: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.MODEL_NOT_FOUND(), ) ``` Note: `get_task_model_id()` would also need a small adjustment — when the chat model isn't in `models`, the `connection_type` lookup fails, so the function should default to trying the external task model when the chat model is unknown: ```python def get_task_model_id(default_model_id, task_model, task_model_external, models): task_model_id = default_model_id if models.get(task_model_id, {}).get('connection_type') == 'local': if task_model and task_model in models: task_model_id = task_model else: # This branch also handles the case where default_model_id is not in models # (e.g., direct connection models), correctly falling back to external task model if task_model_external and task_model_external in models: task_model_id = task_model_external return task_model_id ``` ### Environment - `ENABLE_DIRECT_CONNECTIONS=true` - `ENABLE_OLLAMA_API=False` - Server-level OpenAI connection configured with models - Task Model configured in Admin Settings - Multiple users relying on direct connections for chat
Author
Owner

@champumbc commented on GitHub (Apr 24, 2026):

In the interest of full disclosure - I worked with Claude code to create this issue, but the problem is indeed verified by me.

<!-- gh-comment-id:4314693670 --> @champumbc commented on GitHub (Apr 24, 2026): In the interest of full disclosure - I worked with Claude code to create this issue, but the problem is indeed verified by me.
Author
Owner

@champumbc commented on GitHub (Apr 24, 2026):

PR with fix: https://github.com/open-webui/open-webui/pull/24099

<!-- gh-comment-id:4315185268 --> @champumbc commented on GitHub (Apr 24, 2026): PR with fix: https://github.com/open-webui/open-webui/pull/24099
Author
Owner

@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)

<!-- gh-comment-id:4315223889 --> @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)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#35710