From 1808d7fd2fd32920ef14b8a2502abe7f3c0d9351 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 23 Feb 2026 20:52:12 +0100 Subject: [PATCH] feat: sort action buttons by valve priority (#21790) feat: sort action buttons by valve priority Action buttons under assistant messages were rendered in non-deterministic order due to set() deduplication. They now respect the priority field from function Valves, sorted ascending (lower value = appears first, default 0), matching the existing filter priority mechanism. --- backend/open_webui/utils/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/open_webui/utils/models.py b/backend/open_webui/utils/models.py index 6040c0645..d890dc0a2 100644 --- a/backend/open_webui/utils/models.py +++ b/backend/open_webui/utils/models.py @@ -331,12 +331,18 @@ async def get_all_models(request, refresh: bool = False, user: UserModel = None) elif meta.get(key) is None: meta[key] = copy.deepcopy(value) + def get_action_priority(action_id): + valves = Functions.get_function_valves_by_id(action_id) + return valves.get("priority", 0) if valves else 0 + for model in models: action_ids = [ action_id for action_id in list(set(model.pop("action_ids", []) + global_action_ids)) if action_id in enabled_action_ids ] + action_ids.sort(key=get_action_priority) + filter_ids = [ filter_id for filter_id in list(set(model.pop("filter_ids", []) + global_filter_ids))