From 90116cd36f489d3caec0c592661e30fcc289ce7f Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 24 Nov 2026 20:11:30 +0100 Subject: [PATCH] fix: large chats with no machine selected open slowly (#34963) Opening a chat with no machine selected read through the whole conversation on every open, looking for a machine to restore. That is the normal case for a chat, so large chats opened about 45% slower. A chat that already saved its selection, with no machine or with a machine saved under its former terminal name, now opens without that extra pass. Agent chats with nothing saved still get their machine and folder back. Fastest of seven opens of a 130 MB chat on SQLite:
Context Compaction offContext Compaction on
dev before Terminals were renamed to Machines0.316 s0.429 s
dev0.469 s0.608 s
this fix0.325 s0.437 s
Fixes #34962 --- backend/open_webui/utils/agents/session.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/open_webui/utils/agents/session.py b/backend/open_webui/utils/agents/session.py index cc01cc9b4b..d3ea4e07a7 100644 --- a/backend/open_webui/utils/agents/session.py +++ b/backend/open_webui/utils/agents/session.py @@ -4,7 +4,7 @@ import hashlib import re from urllib.parse import quote -from open_webui.utils.machines import machine_id_of, normalize_machine_id +from open_webui.utils.machines import normalize_machine_id from open_webui.models.chat_messages import ChatMessages from open_webui.models.chats import ChatModel, Chats from open_webui.utils.auth import decode_token @@ -19,8 +19,8 @@ def model_id(state): async def ensure_chat_selections(chat): - data = chat.chat or {} - if all(key in data for key in ('models', 'working_directory')) and machine_id_of(data) is not None: + data = normalize_machine_id(dict(chat.chat or {})) + if all(key in data for key in ('models', 'machine_id', 'working_directory')): return chat state = await get_session(chat) if not state: