From 60ded561a92b868d7cea4dd3d0af683c4359de44 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Thu, 24 Sep 2026 05:51:29 +0200 Subject: [PATCH] fix: load models before resolving automation model defaults (#30379) Automations lost their model's tool bindings (including MCP servers), default features such as web search, default filters and terminal on the first run after a restart. The model then answered that it had no tools. Later runs and a manual Regenerate worked. Automations on the base models cache were not affected. The run read the model from app.state.MODELS before anything had loaded it. After a restart or a connection settings save, that cache stays empty until a browser loads the model list or a chat completion runs. The completion runs only after the automation has already built its request. execute_automation now loads the models when the cache is empty, using the same guard chat_completion uses, before either the chat or the channel target reads it. This also fixes channel automations showing the raw model ID in place of the model name on a cold cache. Verified end to end on a restarted instance with a mock upstream: before, both chat and channel runs reached the pipeline without tool_ids or features. After, both carry the model's tools and web search, and the upstream receives the tool. Fixes #27694 --- backend/open_webui/utils/automations.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/open_webui/utils/automations.py b/backend/open_webui/utils/automations.py index 54887467c0..be5d6868f1 100644 --- a/backend/open_webui/utils/automations.py +++ b/backend/open_webui/utils/automations.py @@ -37,6 +37,7 @@ from open_webui.models.messages import MessageForm from open_webui.models.users import Users from open_webui.utils.auth import create_token from open_webui.utils.misc import parse_duration +from open_webui.utils.models import get_all_models from open_webui.utils.recurrence import ( _resolve_tz, next_n_runs_ns, @@ -390,6 +391,9 @@ async def execute_automation(app, automation: AutomationModel) -> None: expires_delta=expires_delta or timedelta(hours=1), ) + if not app.state.MODELS: + await get_all_models(_build_request(app, token=token), user=user) + target = automation.data.get('target') or {} if target.get('type') == 'channel': await _execute_channel_automation(app, automation, user, prompt, model_id, token)