From cdd96e5b575278047f8b28736fc5a7189cf0ff43 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sat, 10 Oct 2026 17:47:46 +0200 Subject: [PATCH] fix: chat title shows raw skill syntax when it is named after the first message (#32176) When a chat is named after its first message (title generation off, or the automatic title is blank), a message that starts with a skill picked by typing $ in the message box gave the chat a title like `<$tides-1234|Tides> when is high tide`. The title now shows each picked skill by its name, so the sidebar reads "Tides when is high tide". Fixes #32019 --- backend/open_webui/utils/middleware.py | 5 +++-- backend/open_webui/utils/skills.py | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 6b39e46763..abdfa62f09 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -135,6 +135,7 @@ from open_webui.utils.skills import ( apply_skills_create_prompt, extract_skill_ids_from_messages, has_prior_user_message, + replace_skill_mentions_with_labels, strip_skill_mentions, ) from open_webui.utils.task import ( @@ -3943,7 +3944,7 @@ async def background_tasks_handler(ctx): title = '' if not title: - title = messages[0].get('content', user_message) + title = replace_skill_mentions_with_labels(messages[0].get('content', user_message)) await Chats.update_chat_title_by_id(metadata['chat_id'], title) @@ -3955,7 +3956,7 @@ async def background_tasks_handler(ctx): ) if title == None and len(messages) == 2 and (not messages_map or len(messages_map) <= 2): - title = messages[0].get('content', user_message) + title = replace_skill_mentions_with_labels(messages[0].get('content', user_message)) await Chats.update_chat_title_by_id(metadata['chat_id'], title) diff --git a/backend/open_webui/utils/skills.py b/backend/open_webui/utils/skills.py index 1e7414705d..a895e09107 100644 --- a/backend/open_webui/utils/skills.py +++ b/backend/open_webui/utils/skills.py @@ -32,6 +32,11 @@ def extract_skill_ids_from_messages(messages: list[dict]) -> set[str]: SKILL_MENTION_STRIP_RE = re.compile(rf'<(?:\$({SKILL_ID_RE})(?:\|([^>]*))?|/({SKILL_ID_RE})\|([^>]*))>') +def replace_skill_mentions_with_labels(text: str) -> str: + """Show labelled skill mentions as their label, for plain text such as chat titles.""" + return SKILL_MENTION_STRIP_RE.sub(lambda match: match.group(2) or match.group(4) or match.group(0), text) + + SKILLS_CREATE_RE = re.compile(r'^/skills:create(?:\s+(.*))?$', re.IGNORECASE | re.DOTALL) OPEN_WEBUI_SKILL_AUTHORING_STANDARDS = """\