[PR #21841] [MERGED] fix: resolve valve priority for actions and filters via class instantiation #129954

Closed
opened 2026-05-21 13:38:29 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21841
Author: @Classic298
Created: 2/24/2026
Status: Merged
Merged: 2/24/2026
Merged by: @tjbck

Base: devHead: valve-instantiation


📝 Commits (1)

  • 3a6672b fix: resolve valve priority for actions and filters via class instantiation

📊 Changes

2 files changed (+19 additions, -8 deletions)

View changed files

📝 backend/open_webui/utils/filter.py (+9 -5)
📝 backend/open_webui/utils/models.py (+10 -3)

📄 Description

fix: resolve valve priority for actions and filters via class instantiation

The priority sorting for action buttons and filter execution order read valve data directly from the database JSON column using Functions.get_function_valves_by_id(). This returns only explicitly saved values — when a developer defines priority as a class default in their Valves definition (e.g. priority: int = 5) without ever opening the Valves UI to persist it, the database column remains empty. Every function then resolves to priority 0, and the preceding set() deduplication produces non-deterministic iteration order that the stable sort preserves — resulting in random button placement on every page load.

The fix instantiates the Valves class with database values as keyword overrides: Valves(**(db_valves or {})). This merges any persisted overrides onto the code-defined defaults, matching the pattern already established in the action execution handler, filter processing pipeline, and tool module initialization. A secondary sort key (the function ID) ensures fully deterministic ordering even when multiple functions share the same priority value.

Affected locations:

  • get_action_priority in utils/models.py (action button ordering)
  • get_priority in utils/filter.py (filter execution ordering)

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/21841 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 2/24/2026 **Status:** ✅ Merged **Merged:** 2/24/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `valve-instantiation` --- ### 📝 Commits (1) - [`3a6672b`](https://github.com/open-webui/open-webui/commit/3a6672bf192f42a2e8a49ad0c3cda927e19c117a) fix: resolve valve priority for actions and filters via class instantiation ### 📊 Changes **2 files changed** (+19 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/filter.py` (+9 -5) 📝 `backend/open_webui/utils/models.py` (+10 -3) </details> ### 📄 Description fix: resolve valve priority for actions and filters via class instantiation The priority sorting for action buttons and filter execution order read valve data directly from the database JSON column using Functions.get_function_valves_by_id(). This returns only explicitly saved values — when a developer defines priority as a class default in their Valves definition (e.g. priority: int = 5) without ever opening the Valves UI to persist it, the database column remains empty. Every function then resolves to priority 0, and the preceding set() deduplication produces non-deterministic iteration order that the stable sort preserves — resulting in random button placement on every page load. The fix instantiates the Valves class with database values as keyword overrides: Valves(**(db_valves or {})). This merges any persisted overrides onto the code-defined defaults, **matching the pattern already established in the action execution handler, filter processing pipeline, and tool module initialization**. A secondary sort key (the function ID) ensures fully deterministic ordering even when multiple functions share the same priority value. Affected locations: - get_action_priority in utils/models.py (action button ordering) - get_priority in utils/filter.py (filter execution ordering) ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. --> By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-21 13:38:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#129954