From 5b0a889a744c2e44698f8f17e131cb26beb94fa3 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Thu, 1 Oct 2026 05:52:25 +0200 Subject: [PATCH] fix: apply the custom model fallback to chats sent from the web UI (#31353) With ENABLE_CUSTOM_MODEL_FALLBACK on, a workspace model whose base model is gone should be answered by the first default model. That worked for plain API calls, but every chat sent from the web UI failed with "Model not found" for users and "Model '' was not found" for admins, and no model was called. Web UI chats carry a chat id and a socket session, so the request is split into one task per selected model. Each task was rebuilt with the originally requested model id, which dropped the fallback chosen earlier in the handler. The task for the requested model now keeps the fallback model when one was chosen. The chat still records the workspace model the user picked. Tested end to end against a mock upstream, as user and admin, in new and existing chats: before, every web UI send with such a model errored; after, the default model answers. Healthy models, workspace models with a valid base and multi-model sends behave as before, and with the fallback disabled the chat still fails with "Model not found". Fixes #31345 --- backend/open_webui/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index b7ec53ab7d..7a3ce18b9b 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1822,6 +1822,9 @@ async def chat_completion( if not assistant_message_id: continue + if fallback_model is not None and target_model_id == model_id: + target_model_id = fallback_model['id'] + # Per-model metadata: own message_id + model per_model_metadata = { **metadata,