From b2413f914a7dcbaa50f4c87401252314d73dfbd9 Mon Sep 17 00:00:00 2001 From: Algorithm5838 <108630393+Algorithm5838@users.noreply.github.com> Date: Wed, 25 Feb 2026 22:13:18 +0300 Subject: [PATCH] perf: early-return in get_tools() for empty tool_ids (#21873) Avoids a needless Groups.get_groups_by_member_id() query when no tools are attached to the request. --- backend/open_webui/utils/tools.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index 52b53553d1..82d6671739 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -163,6 +163,9 @@ async def get_tools( request: Request, tool_ids: list[str], user: UserModel, extra_params: dict ) -> dict[str, dict]: """Load tools for the given tool_ids, checking access control.""" + if not tool_ids: + return {} + tools_dict = {} # Get user's group memberships for access control checks