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
This commit is contained in:
Classic298
2026-09-23 23:51:29 -04:00
committed by GitHub
parent e13e523f00
commit 60ded561a9
+4
View File
@@ -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)