[PR #21615] [CLOSED] perf: Optimize tools listing to skip content/specs and batch access grants #41793

Closed
opened 2026-04-25 13:55:40 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21615
Author: @Classic298
Created: 2/19/2026
Status: Closed

Base: devHead: perf-tool-list


📝 Commits (2)

  • 64c6a99 Optimize tools listing to skip content/specs and batch access grants (#164)
  • 1bbd664 Merge branch 'dev' into perf-tool-list

📊 Changes

2 files changed (+93 additions, -13 deletions)

View changed files

📝 backend/open_webui/models/tools.py (+70 -0)
📝 backend/open_webui/routers/tools.py (+23 -13)

📄 Description

The GET /tools/ and GET /tools/list endpoints were loading full Tool
rows including the content column (entire Python scripts) and specs
JSON for every tool, plus running N+1 queries for access grants
(one per tool). Now:

  • get_tools_for_listing() uses column projection to skip content,
    specs, and valves columns
  • Access grants are batch-fetched in a single query via new
    get_grants_by_resources() method on AccessGrants
  • Write-access checks in /list use batch get_accessible_resource_ids()
    instead of per-tool has_access() calls

The full get_tools() method remains for the /export endpoint which
needs complete tool data.

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/21615 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 2/19/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `perf-tool-list` --- ### 📝 Commits (2) - [`64c6a99`](https://github.com/open-webui/open-webui/commit/64c6a996f9226a9102bb11ee6198b6d89c363a74) Optimize tools listing to skip content/specs and batch access grants (#164) - [`1bbd664`](https://github.com/open-webui/open-webui/commit/1bbd664216ff5f76e2950331d522b03a978ba2b0) Merge branch 'dev' into perf-tool-list ### 📊 Changes **2 files changed** (+93 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/models/tools.py` (+70 -0) 📝 `backend/open_webui/routers/tools.py` (+23 -13) </details> ### 📄 Description The GET /tools/ and GET /tools/list endpoints were loading full Tool rows including the content column (entire Python scripts) and specs JSON for every tool, plus running N+1 queries for access grants (one per tool). Now: - get_tools_for_listing() uses column projection to skip content, specs, and valves columns - Access grants are batch-fetched in a single query via new get_grants_by_resources() method on AccessGrants - Write-access checks in /list use batch get_accessible_resource_ids() instead of per-tool has_access() calls The full get_tools() method remains for the /export endpoint which needs complete tool data. ### 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-04-25 13:55:40 -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#41793